Skip to content

Instantly share code, notes, and snippets.

@char0n
Created February 26, 2018 09:01
Show Gist options
  • Save char0n/7c7bed08ddffa2958e7fe842e234cded to your computer and use it in GitHub Desktop.
Save char0n/7c7bed08ddffa2958e7fe842e234cded to your computer and use it in GitHub Desktop.
// in reusable feature instance
import createActions from '../reusable-feature/actions';
import selectors from './selectors';
import { createAction } from 'redux-actions';
const actions = createActions('INSTANCE_1', selectors);
actions['additionalAction'] = createAction(...);
export default actions;
// in reusable feature template
import { handleActions } from 'redux-actions';
export default function createReducers(actions) {
const initialState = {
clickCount: 0,
};
const handlers = {
[actions.incrementClick]: state => ({ ...state, clickCount: state.clickCount + 1 }),
};
if (action.additionalAction) {
handlers[actions.additionalAction] = state => ({ ... });
}
return handleActions(handlers, initialState);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment