Passing values

There will be a lot of cases where .map() was used, but we need to return the original value along with the new value.

One case where this can happen is the user registration. We might want to retrieve a User object and when that is ready, we will get the Access Token. However, there might be a consumer somewhere downstream that needs the value of the Access Token and the user ID that was used to retrieve it.

In general, it is a common necessity to pass some information from the nth step to the n+2 step in the Observable flow, as in this figure:

We can see that we need a User object to retrieve an Access Token. However, the subsequent step again requires a User object so that it that the success of the login can be recorded. Afterward, the Access Token needs to be saved for later use. In the end, we need both of them--an Access Token and a User object to be available in the multiple subsequent operations that follow.

After covering this section, we will be able to work with complex data types, and we will know how to pass information between multiple steps in the flow of an Observable.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.30.19