normal: add interceptor method
betula opened this issue · 2 comments
betula commented
const a = value(5);
const b = value(1);
const unsub = a.interceptor((new_value, current_value, stop?) => {
if (new_value == 1) {
b.set(10);
stop();
return;
}
return current_value + new_value;
});
// stoppable supported
a(1); // b.val === 10, a.val === 5
a(2); // a.val === 7
betula commented
Think about syntax for sub
interceptions
const v = value(0);
const s = signal(0);
v.sub.intercept(s, (v_value, new_signal_value, stop ) => {
///
});
v.intercept.sub // alias
// or
v.sub.intercept(s, (v_value, new_signal_value, prev_signal_value ) => {
stoppable.stop();
});
v.intercept.sub // alias
betula commented
Added to "the stream of conciseness 0.7+ roadmap"