redux-procedures
Redux procedures simplify boilerplate for side-effect routines while maintaining the flexibility of redux-sagas or redux-observables (both fully compartible)
why another lib?
I have been successfully using redux-observables and redux-sagas, but mostly the boilerplate required for them is too large for a simple side-effect.
Another brick of the inspiration was the redux-saga-routines
library, which made it really easy to work with
So the fruit of the idea of combining Promise and routines model is this library.
usage
Create a auth.dux.js - is a login reducer file following Ducks convention:
const loginRequest = axios;const LoginProcedure = ; state = isAuthenticated: false authenticating: false user: false action
Add initialization to your store:
; const middlewares = /* epicMiddleware, sagaMiddleware, yourOtherMiddlewares, */ procedureMiddleware; const store_enhancers = ; const store = ;
Use your routine:
const payload = username password ;const meta = metaValue: 'value' ;
How to pause promise execution until an action arrives:
; ;