This commit is contained in:
Willem Dantuma
2020-02-05 14:57:12 +01:00
parent 1bec8c2038
commit 4eb10aa676
5 changed files with 13 additions and 20 deletions

View File

@@ -40,10 +40,15 @@ export class AppCommonEffects {
@Effect()
initUser$: Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.INITUSER),
switchMap(() => {
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
switchMap(([action, initialized]) => {
if(!initialized) {
return this.userService$.getCurrentUser().pipe(
map((user: IUser) => new appCommonActions.InitUserSuccess(user)),
catchError(error => of(new appCommonActions.Fail(error))))
} else {
return [];
}
}
));