handy-thunks ·
Tools for coding with redux-thunk
Installation
npm i handy-thunks
Overview
The package provides easy way to create, enhance and compose thunks
in order to build flow of any complexity by using following tools:
1. Thunk creators
2. Flow compositors
3. Thunk decorators
- connected(selector)(thunk)
- loading(startAction, endAction)(...loadingArgs)(thunk)
- fallback(fallbackThunk)(thunk)
- followedBy(nextThunk)(thunk)
- cleanUp(cleaningThunk)(thunk)
- onlyIf(predicate)(thunk)
- chained(keySelector)(thunk)
- single(keySelector)(thunk)
- postponed(delay, keySelector)(thunk)
- lazy(thunk)
Example:
./src/flows.js (complicated thunks):
; ;; const withUserId = ;const withLoading = 'ALL'; const fetchUserData = ; fetchUserData;
./src/thunks.js (simple thunks):
;;;;; const loadUser = ; const loadContracts = ; const loadOffers = ;