This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

redux-batched-actions-thunk
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Usage

This library is a frankenstein from redux-auto-batched-actions, redux-batched-action and redux-thunk

import { createStore, applyMiddleware } from 'redux';
import { enableBatching } from 'redux-batched-actions';
import { autoBatchingMiddleware } from 'redux-auto-batched-actions';

const setA = payload => ({type: 'SET_A', payload});
const setB = payload => ({type: 'SET_B', payload});

const reducer = (state={a:0, b:0}, action) => {
    switch (action.type) {
        case 'SET_A': return {...state, a: action.payload}
        case 'SET_B': return {...state, b: action.payload}
        default: return state
    }
}

const saySmthGreat() => console.log('great!')

// Handle bundled actions in reducer
const store = createStore(
    enableBatching(reducer),
    applyMiddleware(autoBatchingMiddleware(
        // thunkExtraArgs
        { saySmthGreat }
    ))
);

store.dispatch([setA(1), setA(2), setB(5)]);

store.getState();

Readme

Keywords

none

Package Sidebar

Install

npm i redux-batched-actions-thunk

Weekly Downloads

7

Version

1.0.4

License

MIT

Unpacked Size

9.96 kB

Total Files

8

Last publish

Collaborators

  • savchenko91