React Redux Utils
Redux
API Loaders
Saga Decorator
react-redux-toolbox
exposes a decorator to wrap your saga between two action dised.
; : SagaType { ;}
In the example above,
type: 'react-redux-toolbox/SHOW_LOADER' loaderName: 'movies'
will be dised before the action, and
type: 'react-redux-toolbox/SHOW_LOADER' loaderName: 'movies'
just after.
Loader reducer
react-redux-toolbox
also provides a reducer that you can add to your store, which will to the actions died by the Saga Decorator to update your store:
;; const rootReducer = ;
A selector is also included:
const isLoading = state: any loaderName: string reducerName = 'loader': boolean
Automatically change your components into Loaders
When using the saga decorator, with the loader
reducer added to your store, wrap your components inside a LoaderWrapper
and a loader will be displayed in their place when the loaderName
is marked as loading.
; ... { return <LoaderWrapper loaderName="movies"> <Movies> </LoaderWrapper> }
Error handling
react-redux-toolbox
exposes a decorator to automatically handle common API errors. For instance:
; const handleApiException = { if __DEV__ console; if !errorresponse Toast; return; Toast;}; const catchApiExceptions = ; : SagaType { ;}
Debug
Setup React Native debugger
Redirect network calls to the react native debugger:
;
Testing
getNodeText
;;;; ;