Created
February 3, 2018 11:49
-
-
Save code-vagabond/fff4b4b3e21a0cff5b274f2710e162b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Effect class for auth effects | |
*/ | |
@Injectable() | |
export class AuthEffects { | |
constructor(private actions$: Actions, | |
private authApi: AuthApi, | |
private authUserApi: AuthUserApi, | |
private authStoreApi: AuthStoreService) {} | |
/** Effect Declarations **/ | |
@Effect() | |
signIn$ = this.actions$ | |
.ofType(AuthActionTypes.SIGN_IN) | |
.switchMap((action: SignInAction) => this.onSignIn(action)); | |
/** Effect Handler **/ | |
onSignIn(action: SignInAction): Observable<Action> { | |
return this.authApi | |
.getTokenUsingCredentials( | |
action.payload.username, | |
action.payload.password | |
) | |
.mergeMap((getTokenResponse: GetTokenResponse) => { | |
return [ | |
tokenRefreshed(getTokenResponse), signedIn(), | |
// new RouterActions.Go({ path: ['/profile'] }) | |
]; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment