Local state inside effect / hooks
AStaroverov opened this issue · 2 comments
AStaroverov commented
I have a question. It's a bad idea for S to create something like a local state for effects (hooks?)?
For example
const $source = S.value(0);
const $target = S.value(0);
$.effect(() => {
const $throttler = S.localValue(0);
const throttler = S.sample($throttler);
const source = $source();
$throttler(throttler + 1);
if (throttler % 3 === 0) {
$target(source);
}
})
$source($source() + 1)
$source($source() + 1)
$source($source() + 1)
yamiteru commented
Yeah it is, just use let