next-ucap-messenger/projects/ucap-webmessenger-app/src/app/store/account/index.ts

41 lines
976 B
TypeScript
Raw Normal View History

2019-09-18 06:02:21 +00:00
import { Type } from '@angular/core';
import { Action, combineReducers, Selector, createSelector } from '@ngrx/store';
import * as AuthenticationStore from './authentication';
2019-10-11 05:01:43 +00:00
import * as InfoStore from './info';
2019-09-18 06:02:21 +00:00
export interface State {
authentication: AuthenticationStore.State;
2019-10-11 05:01:43 +00:00
info: InfoStore.State;
2019-09-18 06:02:21 +00:00
}
2019-10-11 05:01:43 +00:00
export const effects: Type<any>[] = [
AuthenticationStore.Effects,
InfoStore.Effects
];
2019-09-18 06:02:21 +00:00
export function reducers(state: State | undefined, action: Action) {
return combineReducers({
2019-10-11 05:01:43 +00:00
authentication: AuthenticationStore.reducer,
info: InfoStore.reducer
2019-09-18 06:02:21 +00:00
})(state, action);
}
export function selectors<S>(selector: Selector<any, State>) {
return {
AuthenticationSelector: AuthenticationStore.selectors(
createSelector(
selector,
(state: State) => state.authentication
)
2019-10-11 05:01:43 +00:00
),
InfoSelector: InfoStore.selectors(
createSelector(
selector,
(state: State) => state.info
)
2019-09-18 06:02:21 +00:00
)
};
}