Skip to content

Instantly share code, notes, and snippets.

@jaozinfs
Created September 22, 2020 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaozinfs/329522eeec677217c1004c53d6d7a0b1 to your computer and use it in GitHub Desktop.
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
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