From a66982b74c1ee32f8f358d94d9f864ecc7df64d0 Mon Sep 17 00:00:00 2001 From: Nico Haesler Date: Thu, 28 Dec 2017 15:52:39 +0100 Subject: [PATCH] fix rehydrating of feature module state --- src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index d9267c7..068e346 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ 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 @@ -227,7 +228,10 @@ export const localStorageSync = (config: LocalStorageConfig) => ( Handle case where state is rehydrated AND initial state is supplied. Any additional state supplied will override rehydrated state for the given key. */ - if (action.type === INIT_ACTION && rehydratedState) { + if ( + (action.type === INIT_ACTION || action.type === UPDATE_ACTION) && + rehydratedState + ) { state = Object.assign({}, state, rehydratedState); } const nextState = reducer(state, action);