Created
July 18, 2023 22:35
-
-
Save KwabenBerko/cd5bb0030ac4a6d296a92e3468cc58ae to your computer and use it in GitHub Desktop.
Job Status Component
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 JobStatusComponent(private val scope: CoroutineScope): Component { | |
var job: Job? = null | |
var refreshesCount: Int = 0 | |
private set | |
override suspend fun refresh() { | |
if (job?.isActive == false){ | |
job = scope.launch { | |
try { | |
delay(1L) | |
refreshesCount++ | |
} finally { | |
job = null | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment