Skip to content

Instantly share code, notes, and snippets.

@joshwcomeau
Created August 11, 2016 12:59
Show Gist options
  • Save joshwcomeau/290ef17709b68b3a0f4b9667e50ec457 to your computer and use it in GitHub Desktop.
Save joshwcomeau/290ef17709b68b3a0f4b9667e50ec457 to your computer and use it in GitHub Desktop.
Disappointing Ducks
const casetteStatusReducer = constructReducer('idle', () => ({
[VIEW_CASETTES]: 'selecting',
[EJECT_CASETTE]: 'idle',
[HIDE_CASETTES]: 'idle',
[SELECT_CASETTE]: 'loaded',
}));
const selectedReducer = constructReducer(null, (state, action) => ({
[SELECT_CASETTE]: action.id,
}));
const byIdReducer = constructReducer({}, (state, action) => ({
[CASETTES_LIST_RECEIVE]: action.casettes,
}));
const pageNumberReducer = constructReducer(0, state => ({
[GO_TO_NEXT_CASETTE_PAGE]: state + 1,
[GO_TO_PREVIOUS_CASETTE_PAGE]: state - 1,
}));
const pageLimitReducer = constructReducer(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment