rcd27
08/26/2021, 1:08 PMnet
, trying to subscribe to it from @Composable
, but it seems to cancel the subscription coroutine, so connection is lost. I've tried with LaunchEffect(Unit)
but no differences:
var itemsListState by remember { mutableStateOf<List<LootItemViewObject>>(emptyList()) }
val scope = rememberCoroutineScope()
scope.launch {
suggestedItemsRepository
.subscribeForItem(qrCode)
.collect {
itemsListState = it
}
}
I think, I've missed one vital concept of recomposing, can you please help?
This code is placed in @Composable
which renders LazyColumn
of those items. (it is later somehing like LazyColumn { itemsListState.forEach { item { ...} } }
Dominaezzz
08/26/2021, 1:16 PMDominaezzz
08/26/2021, 1:21 PMrcd27
08/26/2021, 2:53 PMLaunchedEffect
, the result was the same. I assume coroutine is canceled, because Flow collection
is canceled.Javier
08/26/2021, 2:55 PMJavier
08/26/2021, 2:58 PMrcd27
08/26/2021, 2:59 PMrcd27
08/26/2021, 3:21 PMZach Klippenstein (he/him) [MOD]
08/26/2021, 8:04 PMFunkyMuse
08/27/2021, 8:27 AM