Following is coded:
PublishSubject.create<Pojo>
.doOnNext{
//..
}
.debounce {
if (timeout > 0) Observable.timer(timeout, TimeUnit.MILLISECONDS)
else Observable.never()
}
As it can be seen, there is an Observable.never()
, what I understand as nothing shall be triggered when timeout is negative.
Accroding to Observable.never()
documentation:
Returns an Observable that never sends any items or notifications to an Observer. This ObservableSource is useful primarily for testing purposes.
Scheduler: never does not operate by default on a particular Scheduler. Type Parameters: T - the type of items (not) emitted by the ObservableSource Returns: an Observable that never emits any items or sends any notifications to an Observer
The "useful primarily for testing purposes" confused me. Is the above example valid with never()? Since it is not disposed explcitly, it that ok?