redux-iterators

0.2.1 • Public • Published

Build Status

redux-iterators

Get better composition out of your action creators with iterators.

// composedActionCreator.js
async function gueryStuff(dispatch) {
  const fetched = await fetch('sum.url.com');
  dispatch(fetchedAction(fetched));
}
 
function mahPromise() {
  return new Promise((resolve, reject) => {
    post('sum.other.url.com')
      .then(() => resolve({ type: 'posted.data' }));
  });
}
 
export function* composedActionCreator() {
  yield { type: 'foo', payload: 'bar' };
  yield queryStuff;
  yield mahPromise();
}
 
// store creation
const store = createStore(
  reducers,
  initialState,
  applyMiddleware(reduxIterator, reduxPromise, reduxThunk)
);
 
// component
dispatch(composedActionCreator());

Package Sidebar

Install

npm i redux-iterators

Weekly Downloads

2

Version

0.2.1

License

MIT

Last publish

Collaborators

  • aabenoja