Created
January 21, 2021 11:12
-
-
Save hasankucuk/302bacd00efe222a1ac9f5b3032fc1d2 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
class DownloadingModel { | |
private val _state = MutableStateFlow<DownloadStatus>(DownloadStatus.NOT_REQUESTED) val state: StateFlow<DownloadStatus> get() = _state | |
suspend fun download() { | |
_state.value = DownloadStatus.INITIALIZED initializeConnection() processAvailableContent { | |
partialData: ByteArray, downloadedBytes: Long, totalBytes: Long -> | |
storePartialData(partialData) _state.value = DownloadStatus.IN_PROGRESS } _state.value = DownloadStatus.SUCCESS | |
} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment