How to update MobX store using AJAX

How to update MobX store using AJAX

Written by burczu

  • You forgot to show how you get your store into “this.props.store.fetchData();”

    IMHO it would be better to just import your store directly in your simple use case. There’s no convincing argument for using dependency injection in javascript. Everything es easily mockable/monkeypatched in JS.

  • Vladimir Migalkin

    You should take a look on https://github.com/mobxjs/mobx-utils and method fromPromise.
    “fromPromise takes a Promise and returns an object with 3 observable properties that track the status of the promise.”

    • awesome! didn’t know it (still learning MobX)… thanks!

      • Vladimir Migalkin

        You welcome!