Skip to content

Instantly share code, notes, and snippets.

@indigoviolet
Created October 4, 2017 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indigoviolet/8f1930ef3d7264e4db4812200b8b6bb6 to your computer and use it in GitHub Desktop.
Save indigoviolet/8f1930ef3d7264e4db4812200b8b6bb6 to your computer and use it in GitHub Desktop.
fin blog embed
// helpers/async.js
import { combineReducers } from 'redux';
export const createAsyncReducer = (type) => {
const loading = (state = false, action) => {
if (action.type === type) {
return action.readyState === REQUEST;
}
return state;
};
const data = (state = null, action) => {
if (action.type === type) {
return action.data;
}
return state;
};
const error = (state = null, action) => {
if (action.type === type) {
return action.error;
}
return state;
};
return combineReducers({ loading, data, error });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment