UNPKG

mst-effect

Version:

Designed to be used with MobX-State-Tree to create asynchronous actions using RxJS.

9 lines (8 loc) 309 B
import { reaction } from 'mobx'; import { Observable } from 'rxjs'; export function reaction$(expression, opts) { return new Observable((observer) => { const dispose = reaction(expression, (current, prev, r) => observer.next({ current, prev, r }), opts); return () => dispose(); }); }