I am curious about current best practices for creating streams from sources that may not conform to an existing stream creation method (https://github.com/cujojs/most/blob/master/docs/api.md)
Example using Firebase's ref.on('child_added', function(snap){})
:
most.fromEvent('child_added', ref) //ERROR
I can't use
.fromEvent
... although ref implements some sort ofon
, it does not seem to conform to the EventEmitter interface (addEventListener, removeEventListener)
ref.on('child_added', function(snap){ emitter.emit('value', snap) })
most.fromEvent('value', emitter)
Manually emitting events, is the best I can think of at the moment...
// https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/create.md
Rx.Observable.create(function(observer){
ref.on('child_added', function(snap){ observer.next(snap) })
})
Is there a similar mechanism to custom create a stream, a la Rx?
Are there better ways I am missing?