1.0.0 • Published 8 years ago

redux-generator-thunk v1.0.0

Weekly downloads
16
License
MIT
Repository
github
Last release
8 years ago

Redux Generator Thunk

Generator thunk middleware for Redux.

npm version npm downloads

npm install --save redux-generator-thunk

Motivation

Redux Generator Thunk middleware allows you to write action creators that return a generator function instead of an action. The generator function receives getState as a parameter.

Examples

An action creator that performs an async action:

const INCREMENT_COUNTER = 'INCREMENT_COUNTER';

const increment = () => {
  return {
    type: INCREMENT_COUNTER
  };
};

const incrementAsync = () => {
  return function* () {
    yield delay(1000);
    yield increment();
  };
}

License

MIT