Skip to content

Instantly share code, notes, and snippets.

View Jswizzy's full-sized avatar

Justin Smith Jswizzy

View GitHub Profile
class MyRepository(private val externalScope: CoroutineScope) { /* ... */ }
class MyApplication : Application() {
// Application-scoped types that any class in the app could access
// using the applicationContext.
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
val myRepository = MyRepository(applicationScope)
}
@Jswizzy
Jswizzy / NavBackStackEntryExt.kt
Last active December 29, 2021 19:02
android utils
/**
* If the lifecycle is not resumed it means this NavBackStackEntry already processed a nav event.
*
* This is used to de-duplicate navigation events.
*/
private fun NavBackStackEntry.lifecycleIsResumed() =
this.lifecycle.currentState == Lifecycle.State.RESUMED