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
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.DisposableEffect | |
import androidx.compose.runtime.State | |
import androidx.compose.runtime.mutableStateOf | |
import androidx.compose.runtime.remember | |
import androidx.compose.ui.platform.LocalLifecycleOwner | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleOwner | |
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers |
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
plugins { | |
// ... | |
} | |
android { | |
// ... | |
} | |
dependencies { | |
// ... |
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
[versions] | |
kotlin = "1.9.22" | |
agp = "8.2.0" | |
dagger = "2.50" | |
anvil = "2.4.8" | |
[plugins] | |
android-application = { id = "com.android.application", version.ref = "agp" } | |
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } | |
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } |
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
@SingleIn(AppScope::class) | |
class UserSessionManager @Inject constructor(private val app: App) { | |
private var _userCoroutineScope: UserCoroutineScope? = null | |
private val userCoroutineScope: CoroutineScope | |
get() = createUserCoroutineScope() | |
fun resetSession() { | |
_userCoroutineScope?.cancel() |
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 UserCoroutineScope( | |
private val parentScope: CoroutineScope | |
) : CoroutineScope by parentScope |
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
@SingleIn(UserScope::class) | |
@MergeSubcomponent(UserScope::class) | |
interface UserComponent { | |
@Subcomponent.Factory | |
interface Factory { | |
fun create( | |
@BindsInstance userSession: UserSession, | |
@BindsInstance userCoroutineScope: UserCoroutineScope, | |
): UserComponent |
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
@SingleIn(AppScope::class) | |
class UserSessionManager @Inject constructor(private val app: App) { | |
private var _userCoroutineScope: UserCoroutineScope? = null | |
private val userCoroutineScope: CoroutineScope | |
get() = createUserCoroutineScope() | |
fun resetSession() { | |
_userCoroutineScope?.cancel() |
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 App : Application() { | |
@Inject lateinit var userSessionManager: UserSessionManager | |
val appComponent: AppComponent by lazy { | |
DaggerAppComponent | |
.factory() | |
.create(this) | |
} |
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
abstract class AppScope private constructor() |
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
@SingleIn(AppScope::class) | |
@MergeComponent(AppScope::class) | |
interface AppComponent { | |
@Component.Factory | |
interface Factory { | |
fun create( | |
@BindsInstance app: App, | |
): AppComponent | |
} |
NewerOlder