Skip to content

Instantly share code, notes, and snippets.

@diousk
Last active May 26, 2020 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diousk/acb8a0afa1eac2974cc0dca0ed8a9d8f to your computer and use it in GitHub Desktop.
Save diousk/acb8a0afa1eac2974cc0dca0ed8a9d8f to your computer and use it in GitHub Desktop.
@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