Strange sample code?
tatsuyafujisaki opened this issue · 0 comments
tatsuyafujisaki commented
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 // …
).