Created
March 24, 2021 13:12
-
-
Save vegeta2102/7ff4fe4eefe3c969fd20ec9477df686c to your computer and use it in GitHub Desktop.
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
interface ProgressBarRepository { | |
val data: Flow<Int> | |
suspend fun startCountDown(count: Int) | |
} | |
class ProgressBarRepositoryImpl @Inject constructor() : ProgressBarRepository { | |
private val _data: MutableStateFlow<Int?> = MutableStateFlow(null) | |
override val data: Flow<Int> | |
get() = _data.filterNotNull() | |
override suspend fun startCountDown(count: Int) { | |
epeat(count) { | |
_data.emit(count - it) | |
// Delay 1 sec | |
delay(1000L) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment