Вы можете использовать этот модуль для реализации постоянного состояния приведения https://github.com/btroncone/ngrx-store-localstorage
Реализация
npm install ngrx-store-localstorage --save
ОБНОВЛЕНИЕ ДЛЯ NGRX 4
Обернуть localStorageSync в экспортированную функцию.Включите в свой массив метаредукторов в StoreModule.forRoot.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { StoreModule, ActionReducerMap, ActionReducer, MetaReducer } from '@ngrx/store';
import { localStorageSync } from 'ngrx-store-localstorage';
import { reducers } from './reducers';
const reducers: ActionReducerMap<IState> = {todos, visibilityFilter};
export function localStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
return localStorageSync({keys: ['todos']})(reducer);
}
const metaReducers: Array<MetaReducer<any, any>> = [localStorageSyncReducer];
@NgModule({
imports: [
BrowserModule,
StoreModule.forRoot(
reducers,
{metaReducers}
)
]
})
export class MyAppModule {}