Skip to content

Instantly share code, notes, and snippets.

@zoitsa
Last active November 13, 2019 05:11
Show Gist options
  • Save zoitsa/a1c1e5f8618d224e9cec5e20714cb2d5 to your computer and use it in GitHub Desktop.
Save zoitsa/a1c1e5f8618d224e9cec5e20714cb2d5 to your computer and use it in GitHub Desktop.
Debugging Ngrx 2017 - TNS/NG Reducer
import { ActionReducer, ActionReducerMap, MetaReducer, createFeatureSelector, createSelector } from '@ngrx/store';
import * as fromCategory from './category';
import * as fromSkill from './skill';
import * as fromUser from './user';
import * as fromAvailability from './availability';
import * as fromBooking from './booking';
import * as moment from 'moment';
export interface State {
category: fromCategory.State;
skill: fromSkill.State;
user: fromUser.State;
availability: fromAvailability.State;
booking: fromBooking.State;
}
export const reducers: ActionReducerMap<State> = {
category: fromCategory.reducer,
skill: fromSkill.reducer,
user: fromUser.reducer,
availability: fromAvailability.reducer,
booking: fromBooking.reducer,
};
export function logger(reducer: ActionReducer<State>): ActionReducer<any, any> {
return (state: State, action: any): State => {
console.log('state');
console.log(JSON.stringify(state));
console.log('action');
console.log(JSON.stringify(action));
return reducer(state, action);
};
}
// tslint:disable-next-line:array-type
export const metaReducers: MetaReducer<any, any>[] = [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment