I have an infinite flow of items, coming from the
net
, 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 { ...} } }