redux-sync-promise
redux-sync-promise
Middleware for writing asynchronous actions in synchronous style
Installation
$ npm install --save redux-sync-promiseUsage
Add middleware
import { APISync } from 'redux-sync-promise';
const api = APISync({/* options */});
const createMiddleware = applyMiddleware(thunk, api);
const store = createMiddleware(createStore)(reducer);Action Examples
Every action will dispatch type name from types plus postfix.
API
APISync exposes single constructor function for creating middleware.
APISync( options: Object )
postfix
Add your custom action type postfix for API call.
Default: PENDING, SUCCESS, FAILURE
onPending
Callback when actions in progress
onSuccess
Callback on success
onError
Callback on error
off
Global disable dispatching SUCCESS, PENDING or FAULURE event
Reducer create helper
Standart wrapper for create reducers. I use it on some projects , for this reason, he added to the package
License
Copyright © 2016 Alexander Dukhovnyak
Released under the MIT license. See license for details.
Last updated
Was this helpful?