switch Map
Maps the current value of this Observable to an inner observable through transform, and mirrors the inner observable of the most recent value only: whenever this observable emits, the previous inner observable is unsubscribed and the new one is followed.
This is the switchMap operator of the ReactiveX convention, also known as flatMapLatest in Kotlin flows. Unlike flatMap in the same convention, which merges the emissions of every inner observable created so far, inner observables that are no longer selected stop affecting the result.
Return
an Observable whose value is the current value of the observable returned by transform for the current value of this observable.
Parameters
transform
a function that returns an Observable for each item emitted by the source.