alien-signals
Advanced tools
Comparing version 0.4.11 to 0.4.12
{ | ||
"name": "alien-signals", | ||
"version": "0.4.11", | ||
"version": "0.4.12", | ||
"sideEffects": false, | ||
@@ -41,3 +41,3 @@ "license": "MIT", | ||
"test": "vitest run", | ||
"bench": "npm run build:esm && node --jitless --expose-gc benchs/propagate.mjs" | ||
"bench": "npm run build:esm && node --jitless --expose-gc benchs/propagate.mjs && node --jitless --expose-gc benchs/complex.mjs" | ||
}, | ||
@@ -44,0 +44,0 @@ "devDependencies": { |
@@ -12,2 +12,3 @@ <p align="center"> | ||
<p>[<a href="https://github.com/medz/alien-signals-dart">Alien Signals in Dart</a>]</p> | ||
<p>[<a href="https://github.com/Rajaniraiyn/react-alien-signals">React Binding</a>]</p> | ||
</h3> | ||
@@ -98,17 +99,15 @@ | ||
const sub = link.sub; | ||
let subFlags = sub.flags; | ||
const subFlags = sub.flags; | ||
if (!(subFlags & SubscriberFlags.Tracking)) { | ||
let canPropagate = !(subFlags >> 2); | ||
if (!canPropagate) { | ||
if (subFlags & SubscriberFlags.CanPropagate) { | ||
sub.flags = (subFlags & ~SubscriberFlags.CanPropagate) | targetFlag; | ||
canPropagate = true; | ||
} else if (!(subFlags & targetFlag)) { | ||
sub.flags = subFlags | targetFlag; | ||
} | ||
} else { | ||
sub.flags = subFlags | targetFlag; | ||
} | ||
if (canPropagate) { | ||
if ( | ||
( | ||
!(subFlags & (SubscriberFlags.InnerEffectsPending | SubscriberFlags.ToCheckDirty | SubscriberFlags.Dirty)) | ||
&& (sub.flags = subFlags | targetFlag, true) | ||
) | ||
|| ( | ||
subFlags & SubscriberFlags.Recursed | ||
&& (sub.flags = (subFlags & ~SubscriberFlags.Recursed) | targetFlag, true) | ||
) | ||
) { | ||
const subSubs = (sub as Dependency).subs; | ||
@@ -119,3 +118,3 @@ if (subSubs !== undefined) { | ||
'notify' in sub | ||
? SubscriberFlags.RunInnerEffects | ||
? SubscriberFlags.InnerEffectsPending | ||
: SubscriberFlags.ToCheckDirty | ||
@@ -131,6 +130,8 @@ ); | ||
} | ||
} else if (!(subFlags & targetFlag)) { | ||
sub.flags = subFlags | targetFlag; | ||
} | ||
} else if (isValidLink(link, sub)) { | ||
if (!(subFlags >> 2)) { | ||
sub.flags = subFlags | targetFlag | SubscriberFlags.CanPropagate; | ||
if (!(subFlags & (SubscriberFlags.InnerEffectsPending | SubscriberFlags.ToCheckDirty | SubscriberFlags.Dirty))) { | ||
sub.flags = subFlags | targetFlag | SubscriberFlags.Recursed; | ||
const subSubs = (sub as Dependency).subs; | ||
@@ -141,3 +142,3 @@ if (subSubs !== undefined) { | ||
'notify' in sub | ||
? SubscriberFlags.RunInnerEffects | ||
? SubscriberFlags.InnerEffectsPending | ||
: SubscriberFlags.ToCheckDirty | ||
@@ -168,5 +169,8 @@ ); | ||
const depFlags = dep.flags; | ||
const linkValue = link.value; | ||
if (depFlags & SubscriberFlags.Dirty) { | ||
if (dep.update() !== linkValue) { | ||
if (dep.update()) { | ||
const subs = dep.subs!; | ||
if (subs.nextSub !== undefined) { | ||
shallowPropagate(subs); | ||
} | ||
return true; | ||
@@ -176,3 +180,7 @@ } | ||
if (checkDirty(dep.deps!)) { | ||
if (dep.update() !== linkValue) { | ||
if (dep.update()) { | ||
const subs = dep.subs!; | ||
if (subs.nextSub !== undefined) { | ||
shallowPropagate(subs); | ||
} | ||
return true; | ||
@@ -182,8 +190,3 @@ } | ||
dep.flags = depFlags & ~SubscriberFlags.ToCheckDirty; | ||
if (dep.currentValue !== linkValue) { | ||
return true; | ||
} | ||
} | ||
} else if (dep.currentValue !== linkValue) { | ||
return true; | ||
} | ||
@@ -190,0 +193,0 @@ } |
@@ -11,4 +11,4 @@ import { Dependency, Link } from './system.js'; | ||
constructor(currentValue: T); | ||
get(): NonNullable<T>; | ||
get(): T; | ||
set(value: T): void; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
67061
31
2141
201