Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active April 13, 2022 11:40
Show Gist options
  • Save manuelvicnt/9943e63dba2b87ad64f2f028303a629b to your computer and use it in GitHub Desktop.
Save manuelvicnt/9943e63dba2b87ad64f2f028303a629b to your computer and use it in GitHub Desktop.
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
public fun LifecycleOwner.addRepeatingJob(
state: Lifecycle.State,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
block: suspend CoroutineScope.() -> Unit
): Job = lifecycleScope.launch(coroutineContext) {
repeatOnLifecycle(state, block)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment