create

fun <T> create(onSubscribe: (subscriber: Subscriber<in T>) -> Unit): Observable<T>

Creates a new cold Observable. When the observable is subscribed to, onSubscribe is called with the subscriber as a parameter, and should start emitting to the subscriber using Subscriber.onNext.

onSubscribe should always end with either Subscriber.onError or Subscriber.onCompleted.

Note that the resulting Observable is not backpressure-aware.

Return

a cold Observable

Parameters

T

the type of data that the subscriber will receive

onSubscribe

a function that is called when the observable is subscribed to

See also