60 lines
1002 B
TypeScript
60 lines
1002 B
TypeScript
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) => {
|
|
|
|
});
|
|
}
|
|
}
|