Alireza
12/10/2019, 2:55 PMEventBus
? i found this gist: https://gist.github.com/svenjacobs/57a21405b2dda4b62945c22235889d4a , but filter
operator of openSubscription()
is mark as deprecated!, is there any better sample code?Adam Powell
12/10/2019, 3:12 PM.asFlow()
on the broadcast channel and then operator chain from there instead. Strongly consider using offer
or declaring your send
method suspend
instead of `launch`ing internally. The filter
followed by map
for the cast would be better written .mapNotNull { it as? T }
or filterIsInstance
Alireza
12/10/2019, 3:52 PMinline fun <reified T> listen(): Flow<T> {
return channel.asFlow().filter { it is T }.map { it as T }
}
can you show me an example of using offer()
or send()
for my listen method? according to your first suggested methodbdawg.io
12/10/2019, 5:37 PMasFlow().filterIsInstance<T>()
Gerard Klijs
12/10/2019, 7:27 PM