Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including mobx-suspend with all npm packages installed. Try it out:

var mobxSuspend = require("mobx-suspend")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mobx-suspend v0.0.2

mobx utilities to suspend/unsuspend reactions


npm version build status npm downloads

mobx utilities to suspend/unsuspend reactions

mobx-suspend contains functions you can use instead of the standard mobx reaction and computed features that allows them to be suspended dynamically.


$ npm install mobx-suspend --save

or if using yarn

$ yarn add mobx-suspend

Basic Usage

Suspendable computed

    import {observable,autorun,computed} from 'mobx';
    import {suspendableComputed} from "mobx-suspend";
    const myComputed = suspendableComputed();
    class MyClass {
        value = "initial";
        get actual(){
         return `${this.value}-with-addition`
    const instance = new MyClass();
    instance.value = "first change";
    // console.log is not called
    instance.value = "second change";
    //console.log is not called

Suspendable reaction

    import {suspendableReaction} from "mobx-suspend";
    import {observable} from "mobx";
    const value ="initial");
    const reaction = suspendableReaction(()=>value.get(),v=>console.log(v))
    value.set("new value");
    //the console.log action is not called
    //the console.log action is called with "new value"




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free