Vaibhav Jaiswal
09/25/2023, 2:57 PMveyndan
09/25/2023, 3:14 PMapp.cash.paging.map
)?Vaibhav Jaiswal
09/25/2023, 3:52 PMveyndan
09/25/2023, 4:05 PMVaibhav Jaiswal
09/25/2023, 4:18 PMimport app.cash.paging.insertHeaderItem
import app.cash.paging.map
import app.cash.paging.PagingData
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
class TestViewModel {
val value = flow<PagingData<Int>> {
emit(PagingData.empty<String>())
}.map {
it.map { it.toInt() }
}
val value2 = flow<PagingData<String>> {
emit(PagingData.empty<String>())
}.map {
it.insertHeaderItem(item = "Header")
}
}
insertHeaderItem and map are shown in red, with this error
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
veyndan
09/25/2023, 4:20 PM./gradlew build
from the terminal, does that pass or fail?Vaibhav Jaiswal
09/25/2023, 4:28 PMflow {}
it does not show any error and builds correctlyval value:Flow<PagingData<Int>>
IDE shows error, but builds fineval sourceData = newsRepo.getSourcesList()
.pagedData
.map { it.map { FilterModel.SourceModel(it) as FilterModel } }
.map { it.insertHeaderItem(item = FilterModel.SourceHeader) }
private fun getNewsPaged() = newsRepo.getNews(sourceFilters).pagedData
.cachedIn(coroutineScope)
.onStart { newsRepo.clearAllNews() }
.onEach { _newsData.emit(it) }
.onEach { mutableState.emit(State.Success) }
.launchIn(coroutineScope)
veyndan
09/25/2023, 4:36 PM./gradlew build
is failing, which is more concerning. Do you mind also sharing your build.gradle[.kts]
file?Vaibhav Jaiswal
09/25/2023, 4:40 PMveyndan
09/25/2023, 4:43 PM