Last active
December 5, 2016 09:16
-
-
Save ryo33/fc322c1c1dc2d7877fbc06ef37f6262f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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