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 cancelled through the dispose method. Takes an initial value as second optional argument

Parameters

  • observable IObservableStream<T>
  • initialValue

Examples

  1. const debouncedClickDelta = MobxUtils.fromStream(Rx.Observable.fromEvent(button, 'click')
  2. .throttleTime(1000)
  3. .map(event => event.clientX)
  4. .scan((count, clientX) => count + clientX, 0)
  5. )
  6. autorun(() => {
  7. console.log("distance moved", debouncedClickDelta.current)
  8. })