-
Notifications
You must be signed in to change notification settings - Fork 169
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
Refactor initiazable, Community navhost navigation and fix rare crash in inbox #1210
Conversation
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 have a few concerns about moving the initialized data completely out of the viewmodels, but I mostly blame the jetpack-compose tutorials for not having good examples for how to how to handle intialized data in conjunction with routing.
At some point we might have to entertain moving nearly all the variables out of the viewmodels (and possibly into a stored app state), and have them only consist of functions. When I initially wrote jerboa, the tutorials I'd followed recommended either one, but then most of their examples had data live in the viewmodels.
I trust you and nahweenth's additions for the correct way to do this. Once you get the conflicts resolved, feel free to merge anytime.
InitializeRoute(commentEditViewModel) { | ||
commentEditViewModel.initialize(commentView) | ||
} | ||
val commentView = appState.getPrevReturn<CommentView>(key = CommentEditReturn.COMMENT_SEND) |
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.
This seems like the heart of it here, just an alternate way to send initial data, and remove it from the model.
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.
Even before Jetpack compose passing data between activities was never really done cleanly.
Take a look at IfR does, it uses intents to pass data between activities and Preferences API for persistence
Yeah basically. The big difference here, compared to consumeReturn, is that it never removes the data from the route, it only gets removed when the screen gets popped from backstack.
# Conflicts: # app/src/main/java/com/jerboa/Utils.kt # app/src/main/java/com/jerboa/model/InboxViewModel.kt # app/src/main/java/com/jerboa/ui/components/community/Community.kt # app/src/main/java/com/jerboa/ui/components/inbox/InboxActivity.kt # app/src/main/java/com/jerboa/ui/components/person/PersonProfileActivity.kt
rootChannel
andtakeDepsFromRoot
Fixes #1208
Fixes #1211
@nahwneeth If interested
Just realized that the "forward passing" that I made, is just a reinvention of the
rootChannel
andtakeDepsFromRoot
Hmm not sure which one is better atm
Edit:
I have chosen for my "reinvention" naming is still open for debate. The reason I took this over existing rootChannel is:
I tested everything change by change