The rxjava doc definition of switchmap is rather vague and it links to the same page as flatmap. What is the difference between the two operators?
If you´re looking for an example code
/**
* We switch from original item to a new observable just using switchMap.
* It´s a way to replace the Observable instead just the item as map does
* Emitted:Person{name='Pablo', age=0, sex='no_sex'}
*/
@Test
public void testSwitchMap() {
Observable.just(new Person("Pablo", 34, "male"))
.switchMap(person -> Observable.just(new Person("Pablo", 0, "no_sex")))
.subscribe(System.out::println);
}
You can see more examples here https://github.com/politrons/reactive