June 2017
Intermediate to advanced
400 pages
8h 44m
English
The distinctUntilChanged() function will ignore duplicate consecutive emissions. It is a helpful way to ignore repetitions until they change. If the same value is being emitted repeatedly, all the duplicates will be ignored until a new value is emitted. Duplicates of the next value will be ignored until it changes again, and so on. Observe the output for the following code to see this behavior in action:
import io.reactivex.Observable;public class Launcher { public static void main(String[] args) { Observable.just(1, 1, 1, 2, 2, 3, 3, 2, 1, 1) .distinctUntilChanged() .subscribe(i -> System.out.println("RECEIVED: " + i)); }}
The output of the preceding code snippet is as follows:
RECEIVED: 1RECEIVED: 2RECEIVED: 3 ...
Read now
Unlock full access