```val foo = MutableStateFlow(10) val baz = Mutabl...
# coroutines
m
Copy code
val foo = MutableStateFlow(10)
val baz = MutableStateFlow(10)
foo.collect { baz.value = it }

// Somewhere else
foo.value = 20
assertEquals(20, baz.value) // is this guaranteed? i.e. (how) can I expect value to be immediately updated?
j
This code will hang on the collect, which suspends forever (until cancelled) because the state flow never terminates. So the question is kinda moot
m
Ok, corrected
j
Then it depends on how the coroutine that collects and the coroutine that updates the value are scheduled (it doesn't appear in the sample code). But in this case, you have no suspension point between the moment you set the value of
foo
and the moment you read it from
baz
so the only way the other coroutine can forward the value is if it runs in an other thread at the same time (and if you're lucky). So to answer in general: no, there is no such guarantee