-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
redux-starter-kit includes redux-thunk but doesn't include an async version of createAction. I want to float the idea of a createAsyncAction function that uses thunks; I can create a pull request if all looks good.
Here's a rough initial API proposal:
// To be added:
// (Inspired by the current implementation of `createAction`)
function createAsyncAction(type, thunk) {
const action = payload => thunk(payload);
action.toString = () => type;
return action;
}
// Usage example:
const someAsyncAction = createAsyncAction("SOME_ASYNC_ACTION", payload => {
return dispatch => {
return setTimeout(() => {
// One second later...
dispatch(someAsyncActionSuccess());
}, 1000);
};
});
const someAsyncActionSuccess = createAction("SOME_ASYNC_ACTION_SUCCESS");The only new proposal is at the top of that snippet, the function createAsyncAction. It takes two parameters: type (same as createAction) and thunk.
What are everyone's thoughts?
mshindal, kaleabmelkie, james-innes, tamuhey, joelnet and 6 more
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request