Sometimes there are valid reasons that part of a R...
# coroutines
d
Sometimes there are valid reasons that part of a Reactive System (
Flow
setup) forms a circular reference. In these cases, it's impossible to declare all parts of an overall Flow linearly; at some point we need to reference a part that hasn't been declared yet. In RxJava the idiomatic way to work around this was using
Relay
- a specialised
Subject
. Is there a
Flow
equivalent? It seems that a
MutableSharedFlow
with
replay = 0
will have the right semantics.
e
Depends on the number of subscriptions.
SharedFlow
is designed for multiple subscribers and loses items when there are no subscriptions. If you need guaranteed delivery and expect that a single subscriber comes at a later point in time, then
Channel
is a better solution.
💡 2
d
Thanks @elizarov . I see that
Channel
can be a better choice; guaranteed delivery and no sharing mechanism which may be extraneous if we're looking to merely join a 'loop' (at least with 
consumeAsFlow()
).