Created
September 22, 2020 14:31
-
-
Save jaozinfs/329522eeec677217c1004c53d6d7a0b1 to your computer and use it in GitHub Desktop.
Retorna um flow que emite inteiros do startPosition até count, quando chega no final ele é reiniciado
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun flipModuleFlow(startPosition: Int, count: Int, delayMillis: Long = 2_000) = flow { | |
var s = startPosition % count | |
do { | |
emit(s) | |
delay(delayMillis) | |
s = (s + 1) % count | |
} while (coroutineContext.isActive) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment