<@UHAJKUSTU> Since sample apps use Reaktive, I don...
# decompose
e
@Arkadii Ivanov Since sample apps use Reaktive, I don’t fully understand what is the recommended approach for passing the output of the component. For example if I specify the component this way:
I have to call
emit
from a coroutine context/suspend function. Which probably is not desired. On the other hand I can replace all outputs with lambda-parameters, which can look heavy with a lot of them.
Or should I use a single lambda with only
Output
parameter?
a
You can call
tryEmit
instead, which doesn't require a coroutine context.
In this case you can either pass
output: (Output) -> Unit
, or separate callbacks per output kind.
I would use separate callbacks personally.
e
Could you please advise what are the benefits of using Flow in this case instead of regular callback-lambdas? In what case it could be useful?
In the sample
Consumer
is used. I suppose it should make some sense.
a
You can pass
Flow
to a component to allow it receiving events (inputs), or pass
StateFlow
for states. You can pass a callback (or a number of callbacks) for outputs.
Yes, because Reaktive has
Consumer
type. A normal callback could be used instead.
Just use normal callbacks as it's a general practice.
e
Yeah, I tried to mimic the Reactive sample first and then asked myself what are the benefits and was not able to figure out some. Thank you for advise!
👍 1