Hi, I have a player MVI that seems to have trouble...
# mvikotlin
r
Hi, I have a player MVI that seems to have trouble receiving labels from the
store.labels
flow labels quickly after creation (nothing gets emitted from
store.labels
) - I was wondering if the
labelsChannel
is the best way to go and i guess i should bind manually and not use the standard
Binder
? is that the recommended way?
a
Most likely labels are emitted before the subscription happens. In this case
labelsChannel
won't help either (it's designed to not miss emissions while the app is in background or the screen is in the back stack). Most likely you need manual
init
. See "Initializing a Store" here: https://arkivanov.github.io/MVIKotlin/store.html
r
yeah it seems to do something just by switching to
labelsChannel
i seem to get the missing labels (commit below) - i guess the channel must be buffering the labels. though i guess the labels channel will emit anything unconsumed if I reconnect to it (i.e. go out of and return to my activity)? but now i see your docs on
autoInit = false
in the
labelsChannel
do you think its best to do manual init and use the flows? or use the
labelsChannel
? i guess either is good https://github.com/sentinelweb/cuer/pull/501/commits/58101773f0a03eb80f7c4efb8feebf2647020633
a
If you receive labels via
labelsChannel
and don't receive via
labels
, then probably there is something else. The channel is only created when you call
labelsChannel()
function. It's actually supposed to be called right after the store creation. Calling it a second time will create another channel. In your case, I think it's better to use manual init. The flow is usually as follows: 1. Create a store 2. Subscribe/bind everything 3. Call init()
r
ok brilliant.. thanks for the help..