Skip to content

alkhe/fluxette-thunk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Thunk middleware for fluxette.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published