Mini
02/28/2021, 4:44 PMcombine(snapshotFlow { myMutableStateMap.toMap() }, stateFlowA, stateFlowB)
Adam Powell
02/28/2021, 4:47 PMAdam Powell
02/28/2021, 4:49 PMSnapshot.sendApplyNotifications()
- this will send apply notifications for any snapshot state changes that you've made without a specific snapshot scope.
2. make your relevant snapshot changes inside a Snapshot.withMutableSnapshot {}
block - the snapshot will apply atomically and dispatch to apply observers at the end of the block.Adam Powell
02/28/2021, 4:50 PMmyMutableStateMap
changing inside a Snapshot.withMutableSnapshot {}
block in your test code, or call Snapshot.sendApplyNotifications()
after making those calls. Perform your assertions/await new flow values after whichever one you choose.Mini
02/28/2021, 4:56 PMmyMutableStateMap
with withMutableSnapshot
in the viewmodel, is that correct?
Is there any reason to prefer sendApplyNotifications or withMutableSnapshot in the tests, or is that completely up to my personal preference?Adam Powell
02/28/2021, 5:09 PMmyMutableStateMap
with withMutableSnapshot
in your actual app code unless you want to ensure that if you make several snapshot object changes that they're always seen by different threads as happening atomically. In tests it depends on when you want to publish visibility of changes between threads.Adam Powell
02/28/2021, 5:10 PM