UNPKG

kefir

Version:

Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage

18 lines (15 loc) 449 B
import stream from './stream' import {apply} from '../utils/functions' export default function fromSubUnsub(sub, unsub, transformer /* Function | falsey */) { return stream(function(emitter) { let handler = transformer ? function() { emitter.emit(apply(transformer, this, arguments)) } : x => { emitter.emit(x) } sub(handler) return () => unsub(handler) }).setName('fromSubUnsub') }