fluxette-thunk

0.0.2 • Public • Published

fluxette-thunk

Thunk middleware for fluxette.

Install

npm install --save fluxette-thunk

Usage

Thunks allow you to provide a function, instead of a plain action, to the flux dispatcher. The flux object is passed to the function, allowing you to dispatch asynchronously or conditionally, log actions and state, or accommodate other use cases.

import Flux from 'fluxette';
import thunk from 'fluxette-thunk';
 
let flux = Flux(stores).using(thunk);
 
flux.dispatch(({ dispatch }) =>
    asyncRequest(params, (err, res) => {
        if (err) {
            dispatch({ type: DATA_FAILURE, err });
        }
        else {
            dispatch({ type: DATA_SUCCESS, data: res });
        }
    })
)

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i fluxette-thunk

    Weekly Downloads

    2

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • synchronous