-
Notifications
You must be signed in to change notification settings - Fork 0
/
reducer.ts
35 lines (27 loc) · 1.07 KB
/
reducer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ActionReducer, ActionReducerMap } from '@ngrx/store';
import { environment } from '../../environments/environment';
import * as fromOrganization from './organization/reducers';
import * as fromUser from './user/reducers';
export const USER = 'user';
export type USER = 'user';
export const ORGANIZATION = 'organization';
export type ORGANIZATION = 'organization';
export interface RootState {
organization: fromOrganization.State;
user: fromUser.State;
}
export const reducers = {} as ActionReducerMap<RootState>;
reducers.organization = fromOrganization.createReducer(ORGANIZATION);
reducers.user = fromUser.createReducer(USER);
export function logger(reducer: ActionReducer<RootState>): ActionReducer<any, any> {
return (state: RootState, action: any): RootState => {
// tslint:disable-next-line:no-console
console.log('state', state);
// tslint:disable-next-line:no-console
console.log('action', action);
return reducer(state, action);
};
}
export const metaReducers: Array<ActionReducer<any, any>> = !environment.production
? [logger]
: [];