So I have this function where I can emit values with flow but I need to send values periodically and so I used:
fun hereIsAFunction(): Flow<Type> = flow {
Handler.postDelayed({
//This is in Runnable and I can't emit values
emit(value) //Error 'Suspension function can only be called within Coroutine body
}, 1000)
usingOtherFunction()
}
I don't want to block the function 'usingOtherFunction()', that's why I'm using a runnable
Question: Is there any way to emit values with Flow with periodically events? If yes, what should I look into?