subscribe

abstract fun subscribe(observer: Observer<T>): Disposable

Subscribes the given observer to receive updates, including an Observer.onComplete notification when the upstream source terminates.

Use this overload when you need to react to completion — for example when composing operators or when the subscription represents a finite sequence.

Return

A Disposable for cancelling the subscription.

Parameters

observer

The observer to receive values and the completion signal.


open fun subscribe(onNext: Consumer<T>): Disposable

Subscribes the given onNext to receive updates, where no Observer.onComplete is required.

Use this overload when you don't need to react to completion.

Return

A Disposable for cancelling the subscription.

Parameters

onNext

The Consumer to receive emitted values.


open fun subscribe(onNext: Consumer<T>, onComplete: Runnable): Disposable

Subscribes the given onNext to receive updates, and the given onComplete to receive the Observer.onComplete signal

Use this overload when you need to react to both emitted values and completion.

Return

A Disposable for cancelling the subscription.

Parameters

onNext

The Consumer to receive emitted values.

onComplete

The block of code to run upon completion