fromStream
Converts a subscribable, observable stream (TC 39 Observable / RxJS Stream) into an object which stores the current value (as current
). The subscription can be called through the dispose
method. Takes an initial value as second optional argument.
Parameters
observable
(IObservableStream<T>
)initialValue
Examples
const debouncedClickDelta = MobxUtils.fromStream(Rx.Observable.fromEvent(button, 'click')
.throttleTime(1000)
.map(event => event.clientX)
.scan((count, clientX) => count + clientX, 0)
)
autorun(() => {
console.log("distance moved", debouncedClickDelta.current)
})