0.0.2 • Published 9 years ago

fluxette-thunk v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

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 });
		}
	})
)
0.0.2

9 years ago

0.0.1

9 years ago