Last active
January 11, 2024 14:43
-
-
Save itsandreramon/3ad336961a2e3a2917917d33e2342e3d to your computer and use it in GitHub Desktop.
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() | |
_userCoroutineScope = null | |
// ... | |
} | |
fun createSession(id: String) { | |
// ... | |
} | |
private fun createUserCoroutineScope(): UserCoroutineScope { | |
return _userCoroutineScope ?: UserCoroutineScope(CoroutineScope(SupervisorJob())) | |
.also { _userCoroutineScope = it } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment