Vivek Modi
06/10/2022, 10:48 AMval filteredTopics by lazy { MutableStateFlow<List<Topics>>(emptyList()) }
val temp = list.filter { it.topics != null }.filter { it.title == value.title }
filteredTopics.value = temp.firstOrNull()?.topics?.sortedBy { topic -> topic.title } ?: emptyList()
Diego Marzo
06/10/2022, 10:54 AMfilteredTopics.value = list.filter { it.topics != null && it.title == value.title }.firstOrNull()?.topics?.sortedBy { topic -> topic.title } ?: emptyList()
Vivek Modi
06/10/2022, 10:59 AMephemient
06/10/2022, 11:30 AM.filter { ... }.firstOrNull()
== .firstOrNull { ... }
?: emptyList()
== .orEmpty()
Vivek Modi
06/10/2022, 11:35 AMfilter
and you comparing ==
so what will be come there and how it will sort
my list as well?Diego Marzo
06/10/2022, 11:36 AMfilteredTopics.value = list.firstOrNull { it.topics != null && it.title == value.title }
Vivek Modi
06/10/2022, 11:37 AMwhatwillcomehere
.firstOrNull { ... }?Diego Marzo
06/10/2022, 11:37 AMfilteredTopics.value = list.firstOrNull { it.topics != null && it.title == value.title }".orEmpty()" <<< THIS IS WRONG! should be like ephemient mentioned bellow:
filteredTopics.value = list.firstOrNull { it.topics != null && it.title == value.title }?.topics?.sortedBy { it.title }.orEmpty()
Vivek Modi
06/10/2022, 11:38 AMDiego Marzo
06/10/2022, 11:38 AMephemient
06/10/2022, 11:39 AMfilteredTopics.value = list.firstOrNull { it.topics != null && it.title == value.title }?.topics?.sortedBy { it.title }.orEmpty()
Vivek Modi
06/10/2022, 11:40 AMPaul Woitaschek
06/10/2022, 7:23 PMVivek Modi
06/10/2022, 10:24 PMPaul Woitaschek
06/11/2022, 5:30 AMephemient
06/11/2022, 5:39 AMVivek Modi
06/11/2022, 8:48 AM