val flow: Flow<Nothing> = flow {
suspendCancellableCoroutine { /* do nothing */ }
}
👍 1
streetsofboston
10/04/2019, 3:03 PM
Basically, replace the
delay(Long.MAX_VALUE)
call with an empty
suspendCancellableCoroutine
call
e
elizarov
10/05/2019, 4:16 PM
Actually, that is exactly what delay would do if you call it with
Long.MAX_VALUE
— it assumes you suspend forever.
s
streetsofboston
10/05/2019, 5:26 PM
Had some issues with unit-testing code that uses
delay(Long.MAX_VALUE)
, due to Long.MAX_VALUE rolling over to a negative value of you add just 1 millisecond. Maybe that has been fixed in the latest coroutines-test libraries. If not, calling