2018-01-29 06:28:28 +00:00
|
|
|
import { NgModule } from '@angular/core';
|
|
|
|
import { StoreModule } from '@ngrx/store';
|
|
|
|
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
|
|
|
|
import {
|
|
|
|
StoreRouterConnectingModule,
|
|
|
|
RouterStateSerializer,
|
2018-02-27 13:01:13 +00:00
|
|
|
RouterReducerState,
|
2018-01-29 06:28:28 +00:00
|
|
|
} from '@ngrx/router-store';
|
|
|
|
import { EffectsModule } from '@ngrx/effects';
|
|
|
|
import { combineReducers, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
|
|
|
|
|
2018-03-16 08:33:47 +00:00
|
|
|
import { SimpleRouterStateSerializer } from './commons/util/ngrx/router-store/serializer/simple-router-state-serializer';
|
2018-02-27 13:01:13 +00:00
|
|
|
|
2018-01-29 06:28:28 +00:00
|
|
|
import { environment } from '../environments/environment';
|
2018-03-18 11:53:34 +00:00
|
|
|
import * as AppStore from './commons/store';
|
2018-01-29 06:28:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
@NgModule({
|
|
|
|
exports: [
|
|
|
|
StoreModule,
|
|
|
|
],
|
|
|
|
imports: [
|
2018-03-18 11:53:34 +00:00
|
|
|
StoreModule.forRoot(AppStore.REDUCERS),
|
2018-01-29 06:28:28 +00:00
|
|
|
/**
|
|
|
|
* @ngrx/router-store keeps router state up-to-date in the store.
|
|
|
|
*/
|
|
|
|
StoreRouterConnectingModule.forRoot({
|
|
|
|
/*
|
|
|
|
They stateKey defines the name of the state used by the router-store reducer.
|
|
|
|
This matches the key defined in the map of reducers
|
|
|
|
*/
|
|
|
|
stateKey: 'router',
|
|
|
|
}),
|
|
|
|
/**
|
|
|
|
* Store devtools instrument the store retaining past versions of state
|
|
|
|
* and recalculating new states. This enables powerful time-travel
|
|
|
|
* debugging.
|
|
|
|
*
|
|
|
|
* To use the debugger, install the Redux Devtools extension for either
|
|
|
|
* Chrome or Firefox
|
|
|
|
*
|
|
|
|
* See: https://github.com/zalmoxisus/redux-devtools-extension
|
|
|
|
*/
|
|
|
|
StoreDevtoolsModule.instrument({
|
|
|
|
name: 'overFlow WebApp DevTools',
|
2018-02-27 13:01:13 +00:00
|
|
|
maxAge: 50,
|
2018-01-29 06:28:28 +00:00
|
|
|
logOnly: environment.production,
|
|
|
|
}),
|
2018-03-18 11:53:34 +00:00
|
|
|
EffectsModule.forRoot(AppStore.EFFECTS),
|
2018-01-29 06:28:28 +00:00
|
|
|
],
|
|
|
|
providers: [
|
|
|
|
/**
|
|
|
|
* The `RouterStateSnapshot` provided by the `Router` is a large complex structure.
|
|
|
|
* A custom RouterStateSerializer is used to parse the `RouterStateSnapshot` provided
|
|
|
|
* by `@ngrx/router-store` to include only the desired pieces of the snapshot.
|
|
|
|
*/
|
|
|
|
{ provide: RouterStateSerializer, useClass: SimpleRouterStateSerializer },
|
|
|
|
],
|
|
|
|
|
|
|
|
})
|
2018-02-27 13:01:13 +00:00
|
|
|
export class AppStoreModule { }
|