Skip to content

Instantly share code, notes, and snippets.

@darrenmothersele
Created December 20, 2018 14:08
Show Gist options
  • Save darrenmothersele/14497986a31677af6c6584b7d2203faa to your computer and use it in GitHub Desktop.
Save darrenmothersele/14497986a31677af6c6584b7d2203faa to your computer and use it in GitHub Desktop.
import { Actions } from './counter.actions';
import produce from 'immer';
export const initialState = 0;
const producer = (draft, action) => Actions.match(action, {
Increment: () => draft + 1,
Decrement: () => draft - 1,
Reset: () => initialState,
default: () => {}
});
export const counterReducer = produce(producer, initialState);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment