Signals in a functional reactive style
Functional Reactive Programming (FRP) is a programming paradigm for
working with time-varying values, better capturing the temporal aspect of
mutable state. Signal is a data structure representing a time-varying value.
For example, consider the position of the mouse. The signal
represents current mouse position. When the mouse moves, the value changes
Signals can also be transformed and combined without typical hazards of the stateful programs.
Signal is very low level construct that can be used to create signals from scratch:
var signal = require"signalize/signal"var time = signalsetIntervalnextDatenow1000
Signals implement Watchables abstraction which allows one to subscribe and unsubscribe from signal changes:
var watch = require"watchables/watch"var unwatch = require"watchables/unwatch"var end = Datenow + 1000 * 5watchtimeconsole.logvalueif end - value <= 0 unwatchtime onTimechange// => 1352077824718// => 1352077825719// => 1352077826720// => 1352077827721// => 1352077828722// => 1352077829723
npm install signalize