diff --git a/README.md b/README.md index f9861a8..2c90524 100644 --- a/README.md +++ b/README.md @@ -14,19 +14,25 @@ npm install ngrx-store-localstorage --save 4. Invoke composed function with application reducers as an argument to `StoreModule.provideStore`. ```ts import { NgModule } from '@angular/core'; -import { StoreModule, combineReducers } from '@ngrx/store'; +import { StoreModule, ActionReducerMap, ActionReducer } from '@ngrx/store'; import { compose } from '@ngrx/core/compose'; import { localStorageSync } from 'ngrx-store-localstorage'; import { todos, visibilityFilter } from './reducers'; + +const reducers: ActionReducerMap = {todos, visibilityFilter}; + +export function localStorageSyncReducer(reducer: ActionReducer): ActionReducer { + return localStorageSync({keys: ['todos']})(reducer); +} +const metaReducers: Array> = [localStorageSyncReducer]; + @NgModule({ imports: [ BrowserModule, - StoreModule.provideStore( - compose( - localStorageSync({keys: ['todos']}), - combineReducers - )({todos, visibilityFilter}) + StoreModule.forRoot( + reducers, + {metaReducers} ) ] })