Mehdi Haghgoo
01/23/2021, 7:41 PMTimo Drick
01/23/2021, 7:51 PMMehdi Haghgoo
01/23/2021, 8:05 PMTimo Drick
01/23/2021, 8:06 PMAdam Powell
01/23/2021, 8:47 PMAdam Powell
01/23/2021, 8:48 PMMehdi Haghgoo
01/23/2021, 8:48 PMTimo Drick
01/23/2021, 8:49 PMAdam Powell
01/23/2021, 8:54 PMvar currentValue by remember { mutableStateOf(initialValue) }
LaunchedEffect(myFlow) {
myFlow
.map { performSomeMappingOf(it) }
.collect { currentValue = it }
}
Adam Powell
01/23/2021, 8:54 PMLaunchedEffect
, so if you recompose with a different myFlow
, it cancels the old collect operation and starts a new one with the new value of myFlow
Adam Powell
01/23/2021, 8:56 PMlaunchInComposition
so it's required now. If you really have no keys and you want it to last initial composition to full removal from composition, you can write LaunchedEffect(true)
or LaunchedEffect(Unit)
- just like a while (true)
loop, this should always make you look a little bit closer to be sure it's what the author really intended to do.