manueldidonna
08/25/2020, 10:34 PM// fetch all the items when the inventory change
launchInComposition(inventory) {
val currentInventory = inventory.value
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
// fetchAllItems() update the state
currentInventory.fetchAllItems()
}
}
jim
08/25/2020, 10:35 PMChuck Jazdzewski [G]
08/26/2020, 5:08 PMZach Klippenstein (he/him) [MOD]
08/26/2020, 8:06 PMChuck Jazdzewski [G]
08/26/2020, 8:07 PMinventory
is accessed before the snapshot it was created in is applied. Maybe @Adam Powell can give more context on what snapshot launchInComposition
should be running in.Adam Powell
08/26/2020, 8:08 PMonCommit
launchInComposition
doesn't do anything special to try to propagate a current snapshot through the CoroutineContextlaunchInComposition
does not have an opinion on thismanueldidonna
08/26/2020, 8:22 PMChuck Jazdzewski [G]
08/26/2020, 8:22 PMmanueldidonna
08/26/2020, 9:23 PMChuck Jazdzewski [G]
08/28/2020, 12:58 AMwithContext(<http://Dispachers.IO|Dispachers.IO>)
does not ensure it runs after the composition snapshot has been applied which could cause this code to fail. The work-around prevents the withContext
from executing until after composition's snapshot has applied.