Skip to content

redux middleware for handling action creators that return iterators

License

Notifications You must be signed in to change notification settings

aabenoja/redux-iterators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status dependencies Status devDependencies 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());

About

redux middleware for handling action creators that return iterators

Resources

License

Stars

Watchers

Forks

Packages

No packages published