src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K> Observable<T> distinctUntilChanged(Function<? super T, K> keySelector) {
        ObjectHelper.requireNonNull(keySelector, "keySelector is null");
        return RxJavaPlugins.onAssembly(new ObservableDistinctUntilChanged<T, K>(this, keySelector, ObjectHelper.equalsPredicate()));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K> Observable<T> distinctUntilChanged(Function<? super T, K> keySelector) {
        ObjectHelper.requireNonNull(keySelector, "keySelector is null");
        return RxJavaPlugins.onAssembly(new ObservableDistinctUntilChanged<T, K>(this, keySelector, ObjectHelper.equalsPredicate()));
    }
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < K > Observable < T > distinctUntilChanged ( Function < ? super T , K > keySelector ) { ObjectHelper . requireNonNull ( keySelector , "keySelector is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableDistinctUntilChanged < T , K > ( this , keySelector , ObjectHelper . equalsPredicate ( ) ) ) ; }
Returns an Observable that emits all items emitted by the source ObservableSource that are distinct from their
immediate predecessors, according to a key selector function and based on {@link Object#equals(Object)} comparison
of those objects returned by the key selector function.
<p>
<img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/distinctUntilChanged.key.png" alt="">
<p>
It is recommended the keys' class {@code K} overrides the default {@code Object.equals()} to provide
meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.
Alternatively, use the {@link #distinctUntilChanged(BiPredicate)} overload and provide a comparison function
in case the class {@code K} can't be overridden with custom {@code equals()} or the comparison itself
should happen on different terms or properties of the item class {@code T} (for which the keys can be
derived via a similar selector).
<p>
Note that the operator always retains the latest key from upstream regardless of the comparison result
and uses it in the next comparison with the next key derived from the next upstream item.
<p>
Note that if element type {@code T} in the flow is mutable, the comparison of the previous and current
item may yield unexpected results if the items are mutated externally. Common cases are mutable
{@code CharSequence}s or {@code List}s where the objects will actually have the same
references when they are modified and {@code distinctUntilChanged} will evaluate subsequent items as same.
To avoid such situation, it is recommended that mutable data is converted to an immutable one,
for example using {@code map(CharSequence::toString)} or {@code map(list -> Collections.unmodifiableList(new ArrayList<>(list)))}.
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code distinctUntilChanged} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param <K> the key type
@param keySelector
a function that projects an emitted item to a key value that is used to decide whether an item
is distinct from another one or not
@return an Observable that emits those items from the source ObservableSource whose keys are distinct from
those of their immediate predecessors
@see <a href="http://reactivex.io/documentation/operators/distinct.html">ReactiveX operators documentation: Distinct</a>
Returns an Observable that emits all items emitted by the source ObservableSource that are distinct from their immediate predecessors according to a key selector function and based on { @link Object#equals ( Object ) } comparison of those objects returned by the key selector function . <p > <img width = 640 height = 310 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / distinctUntilChanged . key . png alt = > <p > It is recommended the keys class { @code K } overrides the default { @code Object . equals () } to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence . Alternatively use the { @link #distinctUntilChanged ( BiPredicate ) } overload and provide a comparison function in case the class { @code K } can t be overridden with custom { @code equals () } or the comparison itself should happen on different terms or properties of the item class { @code T } ( for which the keys can be derived via a similar selector ) . <p > Note that the operator always retains the latest key from upstream regardless of the comparison result and uses it in the next comparison with the next key derived from the next upstream item . <p > Note that if element type { @code T } in the flow is mutable the comparison of the previous and current item may yield unexpected results if the items are mutated externally . Common cases are mutable { @code CharSequence } s or { @code List } s where the objects will actually have the same references when they are modified and { @code distinctUntilChanged } will evaluate subsequent items as same . To avoid such situation it is recommended that mutable data is converted to an immutable one for example using { @code map ( CharSequence :: toString ) } or { @code map ( list - > Collections . unmodifiableList ( new ArrayList< > ( list ))) } . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code distinctUntilChanged } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >