Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz

Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz

Author:Mateusz Grzesiukiewicz
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2018-09-29T06:54:53+00:00


Moving to MobX

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.

TasksActionTypes.js: There is no need to define this. MobX will take care of it internally.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.