updateComputed<T> function
Recomputes a ComputedReactiveNode and reports whether the pending value changed.
Parameters:
computed: Computed node whose getter should be invoked
Example:
final computedNode = CustomComputedNode<int>(() => 0);
if (updateComputed(computedNode) && computedNode.subs != null) {
shallowPropagate(computedNode.subs!);
}
Implementation
@pragma("vm:prefer-inline")
@pragma("wasm:prefer-inline")
@pragma("dart2js:prefer-inline")
bool updateComputed<T>(ComputedReactiveNode<T> computed) {
++cycle;
computed
..depsTail = null
..flags = ReactiveFlags.mutable | ReactiveFlags.recursedCheck;
final prevSub = setActiveSub(computed);
try {
final oldValue = computed.pendingValue;
return (oldValue != (computed.pendingValue = computed.getter()));
} finally {
activeSub = prevSub;
computed.flags &= ~ReactiveFlags.recursedCheck;
purgeDeps(computed);
}
}