-
Notifications
You must be signed in to change notification settings - Fork 2
Fix stuff #1
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
base: main
Are you sure you want to change the base?
Fix stuff #1
Conversation
| popUpTo(Screen.HomeScreen.route) { | ||
| inclusive = true | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| navigateToHome = { | ||
| navController.navigate(Screen.HomeScreen.route) { | ||
| popUpTo(Screen.SignInScreen.route) { | ||
| inclusive = true | ||
| } | ||
| } | ||
| }, | ||
| setLoggedIn = signInViewModel::signIn, | ||
| isSignedIn = signInViewModel.loggedInState, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, same
| DisposableEffect(key1 = isSignedIn, effect = { | ||
| if (isSignedIn) { | ||
| navigateToHome() | ||
| } | ||
|
|
||
| onDispose { | ||
| } | ||
| }) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| DisposableEffect(isSignedIn) { | ||
| if (!isSignedIn) { | ||
| navigateToSignIn() | ||
| } | ||
|
|
||
| onDispose { | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
@Zhuinden thank you for the PR. Great to see how you were able to resolve the issues that were present. |
No description provided.