Convert Disposable to Kotlin Flow? #1949
-
We want to get real time unread count updates. According to the docs, we should use the lower-level client |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We don't have API for this yet, but we'll look into providing it. In the meantime, you should be able to use the val flow = callbackFlow<ChatEvent> {
val disposable = client.subscribeFor(ChatEventListener { event ->
this.trySendBlocking(event)
})
awaitClose {
disposable.dispose()
}
}
// In a coroutine
flow.collect { event: ChatEvent ->
// ...
} |
Beta Was this translation helpful? Give feedback.
We don't have API for this yet, but we'll look into providing it.
In the meantime, you should be able to use the
callbackFlow
function from kotlinx.coroutines to convert any callback based API into aFlow
. For our event API, that would look something like this (haven't tested it, just a basic draft):