Skip to content

Commit

Permalink
Try replacing lodash with deepmerge (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
bufke authored and btroncone committed Jul 25, 2019
1 parent 40eb667 commit ac54e0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
},
"typings": "./dist/index.d.ts",
"dependencies": {
"lodash.merge": "^4.6.1"
"deepmerge": "^3.2.0"
}
}
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ac54e0e

Please sign in to comment.