In this section, we will refactor the Tasks application to use MobX instead of vanilla Flux.
The Tasks application was developed in the previous chapters. If you have jumped straight to this chapter, please have a look at the application located at src / Chapter 4 / Example 1_ Todo app with Flux, in the GitHub repository.
Before we dive in, install the two packages using the following command:
yarn add mobx mobx-react
Okay, first, let's clean up unneeded pieces:
- AppDispatcher.js: Dispatching is done by MobX using observables behind the scenes.
- TaskActions.js: Actions will now live in TaskStore and work on its state. In MobX, you will most likely end up with many stores, so this is not a big issue—we keep related things together. ...