April 2017
Intermediate to advanced
414 pages
8h 14m
English
To update the listOfTasks key in AsyncStorage whenever a change is made to the state tree, we will call the subscribe method of our store. This creates a change listener to be called whenever an action has been dispatched and the state tree may have been changed.
It accepts a callback as its argument, and within that argument we can call the getState method of the store to access the state tree and retrieve any values we want from it.
Let's modify the index file found in the app folder so that it subscribes to changes to the store, firing a callback that calls saveAsyncStorage and passes it the most recent version of the listOfTasks array in our state tree:
// TasksRedux/app/index.js ... import { saveAsyncStorage ...Read now
Unlock full access