Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange sample code? #21

Closed
tatsuyafujisaki opened this issue Apr 12, 2020 · 0 comments
Closed

Strange sample code? #21

tatsuyafujisaki opened this issue Apr 12, 2020 · 0 comments

Comments

@tatsuyafujisaki
Copy link

The following code from the codelab puzzled me because the private function userJustLoggedIn() was not called from anywhere.

@Singleton
class UserManager @Inject constructor(...) {
    //Remove line
    var userDataRepository: UserDataRepository? = null

    var userComponent: UserComponent? = null
          private set

    fun isUserLoggedIn() = userComponent != null

    fun logout() {
        userComponent = null
    }

    private fun userJustLoggedIn() {
        userComponent = userComponentFactory.create()
    }
}

After checking the actual code, I realized that the above code was slightly oversimplified. It might be nicer if simplification was implied in the explanation (e.g. use an ellipsis // …).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant