Last active
May 26, 2020 13:25
-
-
Save diousk/acb8a0afa1eac2974cc0dca0ed8a9d8f 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
@Singleton | |
class SessionManager @Inject constructor( | |
private val sessionComponentFactory: SessionComponent.Factory | |
) { | |
var sessionComponent: SessionComponent? = null | |
private set | |
fun isUserLoggedIn() = sessionComponent != null | |
fun logout() { | |
sessionComponent = null | |
} | |
fun loginUser() { | |
userJustLoggedIn() | |
} | |
private fun userJustLoggedIn() { | |
if (sessionComponent == null) { | |
sessionComponent = sessionComponentFactory.create() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment