low: stoppable in view
betula opened this issue · 1 comments
betula commented
const v = value(0);
const positive_v = v.view((n) => n >= 0 ? n : stoppable().stop()); // Add stop method to stop signal. (Make external stop siglal interface)
on(positive_v, console.log) // only positive reactions
// but inside value can be any values, and negative too.
// Task: make a positive stream, ignore negative values.
const v = value(0);
const b = value(0);
sync(v, (val) => val >= 0 && b(val));
// what is the method (shortcut) for making it
v.view((dest, val) => val >= 0 && dest(val));
// This is the perfect view.
// or
v.view((val) => val < 0 && stoppable.stop());
// No have reasons for making stoppable in view. Because it will stop only subscribers reaction, but what to be received for direct reading? (undefined)
// That method provide a new entity with the same set of methods.
// But Its only view. Its parts of one entity. Its not a one task.
v.flow((dest, val, prev?) => val >= 0 && dest(val)); // That case is new one.
// That necessary for creating a new entity (signal, value, ready, etc...), from another entity