UNPKG

rx-mobx

Version:

Convert MobX observables to RxJS and vice-versa

15 lines (13 loc) 312 B
import { observable } from 'mobx'; export function rxToMobx(rxSubject) { const mobx = observable(null); rxSubject.subscribe( x => mobx.set(x), e => { throw new Error(e); } ); const dispose = () => { rxSubject.complete(); }; dispose.observe = mobx.observe.bind(mobx); return dispose; }