Custom Redux Middleware - GrasspIt/GrasspReactNativeDriverApp GitHub Wiki

This app uses a custom Redux middleware to make calls to the Grassp API.

The api.tsx file contains schemas for the different entities in state. It also defines the callApi function which handles each fetch request to the API.

It uses normalizr to normalize the JSON from the API response according to the schema. This makes every API response have the same shape, regardless of how nested the data is.

The index.tsx contains the rootReducer which combines the Redux formReducer and the api reducer.

The reducers use lodash as a utility to merge the API response with the Redux state.

The apiReducer calls the entitiesReducer for each action which requires a call to the Grassp API.