Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ryo33
Last active December 5, 2016 09:16
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 ryo33/fc322c1c1dc2d7877fbc06ef37f6262f to your computer and use it in GitHub Desktop.
Save ryo33/fc322c1c1dc2d7877fbc06ef37f6262f to your computer and use it in GitHub Desktop.
import { create as createJsondiffpatch } from 'jsondiffpatch'
import clone from 'clone'
const jsondiffpatch = createJsondiffpatch({})
function reducer(state = {}, action) {
switch (action.type) {
case 'INITIAL_STATE':
const initialState = action.payload
return initialState
case 'PATCH':
const diff = action.diff
return jsondiffpatch.patch(clone(state), diff)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment