js/example-app/packages/member/store/auth.store.ts

60 lines
1002 B
TypeScript
Raw Normal View History

2018-03-17 15:03:13 +00:00
import { Actions } from '@ngrx/effects';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map';
import {
Store,
Action,
Effect,
ofAction,
} from '@loafer/ngrx-store';
import {
Signin,
SigninSuccess,
SigninFailure,
} from './auth.action';
import {
State,
initialState,
} from './auth.state';
import { MemberService } from '../service/member.service';
@Store(initialState)
export class AuthStore {
public constructor(
private actions$: Actions,
private memberService: MemberService,
) {
}
@Action(Signin)
signin(state: State, action: Signin) {
}
@Action(SigninSuccess)
signinSuccess(state: State, action: SigninSuccess) {
}
@Action(SigninFailure)
signinFailure(state: State, action: SigninFailure) {
}
@Effect(Signin)
signinEffect(state: State, { payload }: Signin) {
this.memberService.signin(payload.email, payload.password)
.map((result: any) => {
});
}
}