import { ActionReducer , ActionReducerMap , MetaReducer } from '@ngrx/store' ; import { LocalStorageConfig , localStorageSync } from 'ngrx-store-localstorage' ; import { createSelector } from 'reselect' ; import { environment } from '../environments/environment' ; import { AuthState , authReducer } from './auth/auth.reducers' ; import { FormState , formReducer } from './form/form.reducers' ; import { MenubarState , menubarReducer } from './menubar/menubar.reducers' ; import { RestState , restReducer } from './rest/rest.reducers' ; import { TableState , tableReducer } from './table/table.reducers' ; import { routerReducer , RouterReducerState } from '@ngrx/router-store' ; import { RouterStateUrl } from './router/router.serializer' ; export interface AppState { auth : AuthState ; form : FormState ; menubar : MenubarState ; rest : RestState ; routerReducer : RouterReducerState < RouterStateUrl > ; table : TableState ; } export const reducers = { auth : authReducer , form : formReducer , menubar : menubarReducer , rest : restReducer , routerReducer : routerReducer , table : tableReducer , } ; const localStorageConfig = { keys : [ 'auth' ] , rehydrate : true , storage : localStorage , removeOnUndefined : false , } ; export function localStorageSyncReducer ( reducer ) { return localStorageSync ( localStorageConfig ) ( reducer ) ; } export const metaReducers = ! environment . production ? [ localStorageSyncReducer ] : [ localStorageSyncReducer ] ; export const getRestState = ( state ) => state . rest ; export const getResponse = ( state ) => state . response ; export const getRestResponse = createSelector ( getRestState , getResponse ) ; export const getRouterState = ( state ) => state . routerReducer ; export const getCurrentUrl = createSelector ( getRouterState , ( state ) => state . state && state . state . url ) ; export const getCurrentParams = createSelector ( getRouterState , ( state ) => state . state && state . state . params ) ;