asObservable

fun <T : Any> Flow<T>.asObservable(context: CoroutineContext = EmptyCoroutineContext): Observable<T>(source)

Converts the given flow to a cold observable. The original flow is cancelled when the observable subscriber is disposed.

An optional context can be specified to control the execution context of calls to Observer methods. You can set a CoroutineDispatcher to confine them to a specific thread and/or various ThreadContextElement to inject additional context into the caller thread. By default, the Unconfined dispatcher is used, so calls are performed from an arbitrary thread.