S
S copied to clipboard
Compute value with prev != next check
Hi, how can I create a computed value (with prev != next checking similar to S.value)?
const computed = S(() => compute());
And I need to run all relative computations only if value that compute
returns was changed, but code above run all relative computations even if compute
returns the same value.
Possible solution:
let computed;
S(() => {
if (!computed) {
computed = S.value(compute());
} else {
computed(compute());
}
});
It works as I expected, but it's too large and maybe S exists same functionality out of the box