From 30fcc035260c1ebb01de565373efde691474abc4 Mon Sep 17 00:00:00 2001 From: Congwen Ma Date: Sat, 9 May 2020 02:04:09 -0700 Subject: [PATCH 1/2] (fix): invokes reducer initially when ngrx is adding a feature state --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index b9d7ce5..3a3718a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import * as deepmerge from 'deepmerge'; const INIT_ACTION = '@ngrx/store/init'; const UPDATE_ACTION = '@ngrx/store/update-reducers'; + const detectDate = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/; // correctly parse dates from local storage @@ -273,7 +274,7 @@ export const localStorageSync = (config: LocalStorageConfig) => ( // If state arrives undefined, we need to let it through the supplied reducer // in order to get a complete state as defined by user - if ((action.type === INIT_ACTION) && !state) { + if ((action.type === INIT_ACTION || action.type === UPDATE_ACTION) && !state) { nextState = reducer(state, action); } else { nextState = { ...state }; From d5091d0e1652bb87aa8eda5fd8ee0fcc709f172b Mon Sep 17 00:00:00 2001 From: Congwen Ma Date: Wed, 13 May 2020 10:30:26 -0700 Subject: [PATCH 2/2] Update src/index.ts --- src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 3a3718a..052ae60 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,6 @@ import * as deepmerge from 'deepmerge'; const INIT_ACTION = '@ngrx/store/init'; const UPDATE_ACTION = '@ngrx/store/update-reducers'; - const detectDate = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/; // correctly parse dates from local storage