Skip to content

Instantly share code, notes, and snippets.

@KwabenBerko
Created July 18, 2023 22:35
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 KwabenBerko/cd5bb0030ac4a6d296a92e3468cc58ae to your computer and use it in GitHub Desktop.
Save KwabenBerko/cd5bb0030ac4a6d296a92e3468cc58ae to your computer and use it in GitHub Desktop.
Job Status Component
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