How to access the value of the first .map ()?

1

I'm making an introduction to redux with angle 4, and when I was doing an @ Effect () I came across the following question:

@Effect()
private newUser = this.actions$
    .ofType(UserActions.NEW_USER)
    .map((action: UserActions.NewUser) => action.payload)
    .switchMap((userData: UserCreation) => {
        const headers = new HttpHeaders().set('Content-Type', 'application/json');
        return this.http.post<User>(this.urlService.postNewUserUrl(), userData, { headers, observe: 'body' });
    })
    .map(user => {
        return {type: AuthActions.TRY_SIGNIN, payload: -->{email: userData.email, userData.password}}<--
    });

How can I access the emitted value of the first .map () to be able to use in the following operators? In this case I want to use what was returned to switchMap () through the first map ().

    
asked by anonymous 19.10.2017 / 19:02

1 answer

1

I have decided as follows:

@Effect()
private newUser = this.actions$
    .ofType(UserActions.NEW_USER)
    .map((action: UserActions.NewUser) => action.payload)
    .switchMap((userData: UserCreation) => {
        const headers = new HttpHeaders().set('Content-Type', 'application/json');
        return this.http.post<User>(this.urlService.postNewUserUrl(), userData, { headers, observe: 'body' })
        .map(user => {
            return {type: AuthActions.TRY_SIGNIN, payload: {email: userData.email, password: userData.password} };
        });
    });
    
20.10.2017 / 12:34