Last active
June 16, 2019 13:31
-
-
Save itayod/5ad2c3d3646877176992e2e5c6b8b4ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {StoreModule, MetaReducer, META_REDUCERS} from '@ngrx/store'; | |
import {ROOT_STORAGE_KEYS, LOCAL_STORAGE_KEY} from './app.tokens'; | |
import {LocalStorageService} from './shared/local-storage.service'; | |
import {storageMetaReducer} from './storage.metareducer'; | |
// factory meta-reducer configuration function | |
export function getMetaReducers(saveKeys: string[], | |
localStorageKey: string, | |
storageService: LocalStorageService | |
): MetaReducer<any>[] { | |
return [storageMetaReducer(saveKeys, localStorageKey, storageService)]; | |
} | |
@NgModule({ | |
imports : [ | |
StoreModule.forRoot(reducers) | |
], | |
providers: [ | |
{provide: ROOT_STORAGE_KEYS, useValue: ['layout.theme']}, | |
{provide: ROOT_LOCAL_STORAGE_KEY, useValue: '__app_storage__'}, | |
{ | |
provide : META_REDUCERS, | |
deps : [ROOT_STORAGE_KEYS, ROOT_LOCAL_STORAGE_KEY, LocalStorageService], | |
useFactory: getMetaReducers | |
}, | |
] | |
}) | |
export class AppModule { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment