Skip to content

Conversation

@Zhuinden
Copy link

No description provided.

Comment on lines +68 to +70
popUpTo(Screen.HomeScreen.route) {
inclusive = true
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so I'm understanding correctly. This means that when I'm on the HomeScreen, and I navigate to signIn, the homeScreen is immediately popped off, right? Makes sense to me, but pop* always confuses me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you navigate from home to signin, then home is popped off

Comment on lines +81 to +89
navigateToHome = {
navController.navigate(Screen.HomeScreen.route) {
popUpTo(Screen.SignInScreen.route) {
inclusive = true
}
}
},
setLoggedIn = signInViewModel::signIn,
isSignedIn = signInViewModel.loggedInState,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach so that SignInScreen has no dependency on SignInViewModel

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, same

Comment on lines +140 to +147
DisposableEffect(key1 = isSignedIn, effect = {
if (isSignedIn) {
navigateToHome()
}

onDispose {
}
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this since I don't need an if statement for isSignedIn and instead basically declare the effect with it's key.

I am new to LaunchedEffect and DisposableEffect though so I will have to read up the differences on why you chose to replace LaunchedEffect with Disposable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced it with DisposableEffect because you don't actually need the coroutine that is executed with LaunchedEffect.

Comment on lines +176 to 183
DisposableEffect(isSignedIn) {
if (!isSignedIn) {
navigateToSignIn()
}

onDispose {
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the above. I like that I can almost have a section of "effects" vs just having if statesments littered throughout.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more accurate to say that if your effects aren't defined like this then you'll just have bugs

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugs you say... I wonder what kind would stem from this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly that the effect shouldn't be hidden behind a conditional.

That's part of why your navigation didn't work previously.

@ColtonIdle
Copy link
Owner

@Zhuinden thank you for the PR. Great to see how you were able to resolve the issues that were present.

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

Successfully merging this pull request may close these issues.

2 participants