https://kotlinlang.org logo
#coroutines
Title
# coroutines
l

Larten

11/10/2020, 9:18 AM
Hi all! I have a flow, which emits on database change. The query has a date parameter (today) which filters in the query on the data side. I have to detect the midnight and update the query to show correct data. Is there any good solutions to this?
b

bezrukov

11/10/2020, 9:21 AM
You can make a flow that produces today date, and then you need to use flatMapLatest:
todayFlow.flatMapLatest { today -> dao.query(today) }
❤️ 2
l

Larten

11/10/2020, 9:25 AM
Yeah, good point, thanks 🙂