S
Size: a a a
S
GG
S
S
S
GG
DT
AB

action2 основываясь на данных который возвращает action1. Вопрос как правильно это сделать? SetAuthenticatedUserData вообще не вызывается (.pipe(
switchMap((response: any) => Observable.of(new SetAuthenticationUserData(...), new LoadUserData(...))
))
DT
@Effect()
loadUserData$ = this.actions$
.pipe(
ofType<LoadUserData>(UserActionTypes.LoadUserData),
mergeMap((action) => this.authService.getUserData(action.payload.id, action.payload.token)
.pipe(
map((response) => {
console.log(response);
// tslint:disable-next-line:no-unused-expression
// new CloseModal();
return new SetUserData(response);
}),
catchError(errMessage => of(new SetAuthenticationError({error: errMessage.error})))
)
)
);
AB
@Effect()
loadUserData$ = this.actions$
.pipe(
ofType<LoadUserData>(UserActionTypes.LoadUserData),
mergeMap((action) => this.authService.getUserData(action.payload.id, action.payload.token)
.pipe(
map((response) => {
console.log(response);
// tslint:disable-next-line:no-unused-expression
// new CloseModal();
return new SetUserData(response);
}),
catchError(errMessage => of(new SetAuthenticationError({error: errMessage.error})))
)
)
);
N
N
DT
AB
DT
@Effect()
logIn$ = this.actions$
.pipe(
ofType<LogIn>(AuthenticationActionTypes.LogIn),
switchMap((action) => this.authService.login({
username: action.payload.username,
password: action.payload.password
})
.pipe(
map((response: any) => {
const {id, token, userName, error} = response;
return new SetAuthenticationUserData({
id,
token,
userName,
error,
});
}),
catchError((errMessage: any) => of(new SetAuthenticationError({error: errMessage.error.error}))),
)
),
);
AB
@Effect()
logIn$ = this.actions$
.pipe(
ofType<LogIn>(AuthenticationActionTypes.LogIn),
switchMap((action) => this.authService.login({
username: action.payload.username,
password: action.payload.password
})
.pipe(
map((response: any) => {
const {id, token, userName, error} = response;
return new SetAuthenticationUserData({
id,
token,
userName,
error,
});
}),
catchError((errMessage: any) => of(new SetAuthenticationError({error: errMessage.error.error}))),
)
),
);
@Effect() logIn$ = this.actions$.pipe(
ofType<LogIn>(AuthenticationActionTypes.LogIn),
mergeMap((action) => this.authService.login({
username: action.payload.username,
password: action.payload.password
}).pipe(
switchMap((response: any) => {
const { id, token, userName, error } = response;
const action1 = new SetAuthenticationUserData({
id,
token,
userName,
error,
});
const action2 = new SetUserData(response);
return new Observable.of(action1, action2);
}),
catchError((errMessage: any) => of(new SetAuthenticationError({ error: errMessage.error.error }))),
)
),
);
IB
I
S
I