Skip to content

Commit

Permalink
Update readme for ngrx 4.0 (#47)
Browse files Browse the repository at this point in the history
* Update readme for ngrx 4.0

For some reason, we need to manually specify the type of the meta-reducers, as shown in 
ngrx/platform#170 (comment)

Fixes #45

* Fix readme for ngrx store 4.0

uses fix from #43
  • Loading branch information
saulshanabrook authored and btroncone committed Aug 14, 2017
1 parent f9c0e04 commit 84b36e6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<IState> = {todos, visibilityFilter};

export function localStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
return localStorageSync({keys: ['todos']})(reducer);
}
const metaReducers: Array<ActionReducer<any, any>> = [localStorageSyncReducer];

@NgModule({
imports: [
BrowserModule,
StoreModule.provideStore(
compose(
localStorageSync({keys: ['todos']}),
combineReducers
)({todos, visibilityFilter})
StoreModule.forRoot(
reducers,
{metaReducers}
)
]
})
Expand Down

0 comments on commit 84b36e6

Please sign in to comment.