April 2017
Intermediate to advanced
414 pages
8h 14m
English
The Redux-Thunk library is a wrapper around your action creators, allowing them to perform asynchronous tasks before dispatching their intended action to the Redux store for a reducer to handle.
Here's how we will create a thunk: in the file where we create actions, we will export a function that returns a custom, asynchronous function within it, passing it the existing dispatch method. In this custom function, we will grab the results of a call to our getAsyncStorage method.
Then, within the same method, we will dispatch a private function, which we also create in the same file. That private function will return the action type, along with any parameters we wish to pass:
// TasksRedux/app/actions/index.js import { getAsyncStorage ...Read now
Unlock full access