enroll
list
const channel = const unsubscribe = channel channel// first: can you hear me channel channel// first: your circuit's dead// second: your circuit's dead channel// second: there's something wrong
The implementation is heavily inspired by how subscriptions are implemented in Redux. This is reflected in the tests, some of which are adapted Redux tests.
list([getInitialBroadcast])
getInitialBroadcast
is a function that returns an initial value for the listener to be called with upon subscribe.
Instance methods:
subscribe(listener)
listener
is a function.
broadcast([...args])
tree
const channels = const unsubscribe = channels channels// a1: can you hear me channels channels// a1: your circuit's dead// a2: your circuit's dead// b1: can you hear me channels// a2: there's something wrong
tree([getInitialBroadcast])
getInitialBroadcast
is a function that returns an initial value for the listener to be called with upon subscribe.
Instance methods:
subscribe(listener)
listener
is an object with a single branch, where the outermost node is a function.
broadcast([...args])
Note:
A function identity can only be added to a specific path in the tree once, the same function identity can however be added to multiple unique paths in the same tree (with separate subscribe
calls).
enrollment
Combines list
and tree
.
const channels = channelschannels channels// first onechannels// first { a: 'two' }// second two