Any strong reasons to not do something like that `...
# announcements
j
Any strong reasons to not do something like that
Copy code
private val channel = Channel<Event>()
val events = flow { emit(channel.receive()) }
Use the channel inside a class to expose an api to emit values and receive those values else where as a flow?
a
isn’t that available as
channel.consumeAsFlow()
?
j
it is! i did not know about that one, thanks
a
so yes, I’d say it’s an anticipated usage 😉
a
Note the distinction between
consumeAsFlow
and
receiveAsFlow
- the snippet that started this thread is the latter
1