@webreflection/signals 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/disposable.js +1 -1
- package/dist/signals.js +1 -1
- package/package.json +1 -1
- package/src/index.js +2 -6
package/dist/disposable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r,
|
|
1
|
+
var r,p,u,f,i,n=!0,o=class{static{p=s=>s.#t,u=s=>s.#s,f=(s,e)=>{s.#s=e}}#s=new Set;#t;constructor(s){this.#t=s}get value(){return y(this.#s),this.#t}set value(s){if(this.#t=s,n){let e=this.#s;this.#s=new Set,k(e)}}peek(){return this.#t}},a=Symbol(),h=class extends o{#s=!0;#t;[a](){if(this.#s)return;this.#s=!0;let s=u(this);f(this,new Set),k(s)}get value(){return y(u(this)),this.peek()}peek(){for(;this.#s;)this.#s=!1,this.#t=x(this,p(this));return this.#t}},l=class{disposed=!1;invalid=!0;sub=[];cleanup;fn;constructor(s){this.fn=s}[a](){this.invalid||this.disposed||(this.invalid=!0,i||(r?r.push(this):this.peek()))}peek(){for(;this.invalid&&!this.disposed;)this.invalid=!1,b(this),this.cleanup=x(this,this.fn)}},g=t=>{let s=r;s||(r=[]);try{return t()}finally{if(!s){[s,r]=[r,s];for(let e of s)e.peek()}}},b=t=>{t.cleanup?.(),t.sub.length&&t.sub.splice(0).forEach(d)},m=t=>new h(t),d=t=>{t.disposed=!0,b(t)},v=t=>{let s=new l(t);return i&&i.sub.push(s),s.peek(),()=>{s.disposed||d(s)}},k=t=>{for(let s of t)s[a]()},y=t=>{n&&i&&t.add(i)},x=(t,s)=>{let e=i;i=t;try{return s()}finally{i=e}},S=t=>new o(t),V=t=>{let s=n;n=!1;try{return t()}finally{n=s}};var z=t=>function(...e){let c,w=v(()=>{c??=t.apply(this,e)??this});return c[Symbol.dispose]=w,c};export{h as Computed,o as Signal,g as batch,m as computed,z as disposable,v as effect,S as signal,V as untracked};
|
package/dist/signals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r,
|
|
1
|
+
var r,a,c,f,e,n=!0,o=class{static{a=s=>s.#t,c=s=>s.#s,f=(s,i)=>{s.#s=i}}#s=new Set;#t;constructor(s){this.#t=s}get value(){return k(this.#s),this.#t}set value(s){if(this.#t=s,n){let i=this.#s;this.#s=new Set,d(i)}}peek(){return this.#t}},l=Symbol(),u=class extends o{#s=!0;#t;[l](){if(this.#s)return;this.#s=!0;let s=c(this);f(this,new Set),d(s)}get value(){return k(c(this)),this.peek()}peek(){for(;this.#s;)this.#s=!1,this.#t=v(this,a(this));return this.#t}},h=class{disposed=!1;invalid=!0;sub=[];cleanup;fn;constructor(s){this.fn=s}[l](){this.invalid||this.disposed||(this.invalid=!0,e||(r?r.push(this):this.peek()))}peek(){for(;this.invalid&&!this.disposed;)this.invalid=!1,p(this),this.cleanup=v(this,this.fn)}},w=t=>{let s=r;s||(r=[]);try{return t()}finally{if(!s){[s,r]=[r,s];for(let i of s)i.peek()}}},p=t=>{t.cleanup?.(),t.sub.length&&t.sub.splice(0).forEach(b)},y=t=>new u(t),b=t=>{t.disposed=!0,p(t)},x=t=>{let s=new h(t);return e&&e.sub.push(s),s.peek(),()=>{s.disposed||b(s)}},d=t=>{for(let s of t)s[l]()},k=t=>{n&&e&&t.add(e)},v=(t,s)=>{let i=e;e=t;try{return s()}finally{e=i}},g=t=>new o(t),S=t=>{let s=n;n=!1;try{return t()}finally{n=s}};export{u as Computed,o as Signal,w as batch,y as computed,x as effect,g as signal,S as untracked};
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -140,10 +140,6 @@ export const effect = fn => {
|
|
|
140
140
|
};
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
const forceTracking = value => {
|
|
144
|
-
tracking = value;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
143
|
const notify = subscribers => {
|
|
148
144
|
for (const subscriber of subscribers) subscriber[compute]();
|
|
149
145
|
};
|
|
@@ -169,7 +165,7 @@ export const signal = init => new Signal(init);
|
|
|
169
165
|
/** @type {<T>(fn: () => T) => T} */
|
|
170
166
|
export const untracked = fn => {
|
|
171
167
|
const before = tracking;
|
|
172
|
-
|
|
168
|
+
tracking = false;
|
|
173
169
|
try { return fn() }
|
|
174
|
-
finally {
|
|
170
|
+
finally { tracking = before }
|
|
175
171
|
};
|