UNPKG

flexium

Version:

A lightweight, signals-based UI framework with cross-platform renderers

2 lines 1.02 kB
'use strict';var chunkMOEFWUNZ_js=require('./chunk-MOEFWUNZ.js');var r=new Map;function u(o,T){let e,a={},n=T?.key;if(n&&typeof n=="string"&&r.has(n))e=r.get(n);else {if(typeof o=="function"){let t=o,[s,d]=chunkMOEFWUNZ_js.j(t,async p=>p);e=s,a=d;}else e=chunkMOEFWUNZ_js.b(o);n&&typeof n=="string"&&(e._stateActions=a,r.set(n,e));}!a.refetch&&e._stateActions&&(a=e._stateActions);let f=(()=>e.value);Object.defineProperties(f,{loading:{get:()=>e.loading||false},error:{get:()=>e.error},state:{get:()=>e.state||"ready"},latest:{get:()=>e.latest??e.peek()},read:{value:e.read||(()=>e.value)}});let i=(t=>{if(a.mutate)if(typeof t=="function"){let s=t;a.mutate(s(e.peek()));}else a.mutate(t);else if(typeof t=="function"){let s=t;e.value=s(e.peek());}else e.value=t;});return i.mutate=a.mutate||(t=>{typeof t=="function"?e.value=t(e.peek()):e.value=t;}),i.refetch=a.refetch||(()=>{}),[f,i]}function g(){r.clear();}exports.a=u;exports.b=g;//# sourceMappingURL=chunk-W6V74NAX.js.map //# sourceMappingURL=chunk-W6V74NAX.js.map