Flatten a Higher Order Observable with RxJS switch

André Staltz
InstructorAndré Staltz

Share this video with your friends

Send Tweet
Published 5 years ago
Updated 3 years ago

To consume the higher order RxJS Observable, we had to do a subscribe inside a subscribe. In this lesson, we will learn a better approach using flattening operators, of which switch() is a common and simple one.

Rene
Rene
~ 5 years ago

Is there any way you can include examples with real data?

André Staltz
André Staltzinstructor
~ 5 years ago

Hi Rene. Yes, keep on watching the course and in the 5th lesson from now, there is a real-world example for HTTP requests with switch().

Scott C
Scott C
~ 5 years ago

Why is it called switch? It looks like it just flattens.

André Staltz
André Staltzinstructor
~ 5 years ago

Hi Scott. It performs flattening, and it's called switch because it is one of the flattening strategies, to "switch from the previous inner Observable to the next inner one".