From 84b36e6956bce2c1518c1bbea92af21e600be25d Mon Sep 17 00:00:00 2001 From: Saul Shanabrook Date: Mon, 14 Aug 2017 08:12:23 -0400 Subject: [PATCH] Update readme for ngrx 4.0 (#47) * Update readme for ngrx 4.0 For some reason, we need to manually specify the type of the meta-reducers, as shown in https://github.com/ngrx/platform/issues/170#issuecomment-318031101 Fixes #45 * Fix readme for ngrx store 4.0 uses fix from https://github.com/btroncone/ngrx-store-localstorage/issues/43 --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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} ) ] })