Closed ArseAssassin closed 7 years ago
Can be implemented in user-space:
persistentWires: (fn) => (props) => {
let wires = []
props.isAlive.filter(r.equals(false)).take(1).onValue(() => {
wires.forEach((it) => it.end())
})
let wire = (arg) => {
if (typeof arg === 'string') {
return props.slot(arg).emit
} else if (arg.emit) {
return arg.emit
} else if (arg.call) {
let emitter = kefir.emitter()
wires.push(emitter)
arg(emitter)
return (value) => {
emitter.emit(value)
}
}
}
return { wires: kefir.constant(fn(r.merge(props, { wire }))) }
},
Pros:
Cons:
Both: