ubu
10/07/2019, 2:03 PMclass Handler : MessageHandler {
private val channel = Channel<Message>(1)
override fun handle(message : Message) {
// TODO send event.
}
fun send(event : Message) {
}
/*
fun observe() : Channel<Message>
fun observe() : Flow<Message>
*/
}
When having `RxJava`’s subjects
, I could call onNext()
, let observers consume it by exposing some Observable
. Is there a way to do the same with Coroutines
? I need to expose some methods that allow to observe stream of events received in handle(message : Message)
method. Thanks a lot in advance!zak.taccardi
10/07/2019, 2:04 PMconsumeAsFlow()
or receiveAsFlow()
)ubu
10/07/2019, 2:06 PMzak.taccardi
10/07/2019, 2:07 PMubu
10/07/2019, 2:10 PMzak.taccardi
10/07/2019, 2:12 PMchannel.send(..)
if I am in a coroutine or channel.offer(..)
if I am notubu
10/07/2019, 2:12 PMzak.taccardi
10/07/2019, 2:12 PMchannel.offer(..)
, the Channel’s capacity comes into playubu
10/07/2019, 2:14 PMzak.taccardi
10/07/2019, 2:17 PMFlow<T>
Channels are for communicating between coroutines, or into one from outside of one, and Flow<T>
is for exposing an API of multiple events of T
Pablichjenkov
10/07/2019, 3:30 PM