diff --git a/package.json b/package.json index 4e149ae..64b7b24 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,6 @@ }, "typings": "./dist/index.d.ts", "dependencies": { - "lodash.merge": "^4.6.1" + "deepmerge": "^3.2.0" } } diff --git a/src/index.ts b/src/index.ts index efdc53d..dd1a6f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import * as merge from 'lodash.merge'; +import * as deepmerge from 'deepmerge'; const INIT_ACTION = '@ngrx/store/init'; const UPDATE_ACTION = '@ngrx/store/update-reducers'; @@ -258,7 +258,11 @@ export const localStorageSync = (config: LocalStorageConfig) => ( } if ((action.type === INIT_ACTION || action.type === UPDATE_ACTION) && rehydratedState) { - nextState = merge({}, nextState, rehydratedState); + const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray; + const options: deepmerge.Options = { + arrayMerge: overwriteMerge + }; + nextState = deepmerge(nextState, rehydratedState, options); } nextState = reducer(nextState, action);