@ngrx/store#INIT TypeScript Examples
The following examples show how to use
@ngrx/store#INIT.
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: index.spec.ts From ngrx-issue-tracker with MIT License | 6 votes |
mockState = (override: Partial<RootState> = {}): RootState => {
const initialState = {};
Object.entries(reducers).forEach(([key, reducer]) => {
initialState[key] = reducer(undefined, { type: INIT });
});
return {
...initialState,
...override,
} as RootState;
}
Example #2
Source File: init-state-from-local-storage.reducer.ts From enterprise-ng-2020-workshop with MIT License | 6 votes |
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;
};
}