Add action logging and some refactoring
This commit is contained in:
@@ -11,7 +11,7 @@ import { AppCommonMapModule} from '@farmmaps/common-map';
|
||||
|
||||
import {AppRootComponent} from './app.component';
|
||||
|
||||
import {StoreModule, Store} from '@ngrx/store';
|
||||
import {StoreModule, ActionReducer,MetaReducer} from '@ngrx/store';
|
||||
import {EffectsModule, EffectSources} from '@ngrx/effects';
|
||||
import { StoreRouterConnectingModule} from '@ngrx/router-store';
|
||||
|
||||
@@ -48,6 +48,18 @@ export function provideBootstrapEffects(effects: Type<any>[]) {
|
||||
];
|
||||
}
|
||||
|
||||
// console.log all actions
|
||||
export function debug(reducer: ActionReducer<any>): ActionReducer<any> {
|
||||
return function(state, action) {
|
||||
console.debug('-- State', state);
|
||||
console.debug('-- Action', action);
|
||||
|
||||
return reducer(state, action);
|
||||
};
|
||||
}
|
||||
|
||||
export const metaReducers: MetaReducer<any>[] = [debug];
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppRootComponent,
|
||||
@@ -61,7 +73,7 @@ export function provideBootstrapEffects(effects: Type<any>[]) {
|
||||
AppCommonServiceModule.forRoot(),
|
||||
AppCommonMapModule.forRoot(),
|
||||
BrowserModule,
|
||||
StoreModule.forRoot({},{runtimeChecks: { // TODO fix this should all be true
|
||||
StoreModule.forRoot({},{metaReducers,runtimeChecks: { // TODO fix this should all be true
|
||||
strictStateImmutability: false,
|
||||
strictActionImmutability: false,
|
||||
strictStateSerializability: false,
|
||||
|
Reference in New Issue
Block a user