Billy Newman
02/01/2023, 9:26 PMPablichjenkov
02/01/2023, 9:26 PMBilly Newman
02/01/2023, 9:28 PMprivate val _flow = MutableSharedFlow<String>(
replay = 1,
onBufferOverflow = BufferOverflow.DROP_OLDEST
)
val flow: SharedFlow<String> = _flow
Observe in composable:
val noticeToMarinersGraphic by viewModel.flow.collectAsState(null)
However, even when using a shared flow, changes in the composable state do not force a recompose if the value is the same. Fairly certain that is because compose sees the state as not changingKevin Del Castillo
02/01/2023, 9:30 PMPablichjenkov
02/01/2023, 9:33 PMBilly Newman
02/01/2023, 9:34 PMKevin Del Castillo
02/01/2023, 9:36 PMBilly Newman
02/01/2023, 9:37 PMephemient
02/01/2023, 9:38 PMequals
, you'd absolute be better off fixing that. it could be worked around withval value: T? by remember { mutableStateOf(null, referentialEqualityPolicy()) }
LaunchedEffect(...) {
flow.collect { value = it }
}
Kevin Del Castillo
02/01/2023, 9:39 PM