Not new to Kotlin but new to Flow. Is there a way to rewrite the following code to make it shorter, or do I need to resort to writing my own extension? I need to emit null when the list is empty
Zun
06/06/2021, 1:41 PM
onEmpty{emit(null)}
doesn't work
k
knthmn
06/06/2021, 2:01 PM
Flow.onEmpty()
runs the lambda when the flow finishes without emitting any elements, it has nothing to do with the list being empty
knthmn
06/06/2021, 2:02 PM
also you are trying to transform
showDao.loadHomeScreen()
, you can just use
Flow.map()
z
Zun
06/06/2021, 2:02 PM
I need to emit a list only when it contains entries. If it is empty, I need to emit null