2018-05-28 07:51:33 +00:00
|
|
|
import { Selector, createSelector } from '@ngrx/store';
|
|
|
|
|
|
|
|
import { RESTClientError } from '@loafer/ng-rest';
|
2018-05-29 11:42:39 +00:00
|
|
|
import { Member } from '@overflow/commons-typescript/model/member';
|
2018-05-28 07:51:33 +00:00
|
|
|
|
|
|
|
export interface State {
|
2018-05-29 11:42:39 +00:00
|
|
|
member: Member;
|
2018-05-28 07:51:33 +00:00
|
|
|
pending: boolean;
|
|
|
|
error: RESTClientError;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const initialState: State = {
|
2018-05-29 11:42:39 +00:00
|
|
|
member: null,
|
2018-05-28 07:51:33 +00:00
|
|
|
pending: false,
|
|
|
|
error: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
export function getSelectors(selector: Selector<any, State>) {
|
|
|
|
return {
|
2018-05-29 11:42:39 +00:00
|
|
|
selectMember: createSelector(selector, (state: State) => state.member),
|
2018-05-28 07:51:33 +00:00
|
|
|
selectPending: createSelector(selector, (state: State) => state.pending),
|
|
|
|
selectError: createSelector(selector, (state: State) => state.error),
|
|
|
|
};
|
|
|
|
}
|