@ngrx/store#UPDATE TypeScript Examples

The following examples show how to use @ngrx/store#UPDATE. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: init-state-from-local-storage.reducer.ts    From enterprise-ng-2020-workshop with MIT License 6 votes vote down vote up
export function initStateFromLocalStorage(
  reducer: ActionReducer<AppState>
): ActionReducer<AppState> {
  return function (state, action) {
    const newState = reducer(state, action);
    if ([INIT.toString(), UPDATE.toString()].includes(action.type)) {
      return { ...newState, ...LocalStorageService.loadInitialState() };
    }
    return newState;
  };
}