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

Navigator scoped ScreenModel #233

Merged
merged 3 commits into from
Oct 22, 2023
Merged

Conversation

DevSrSouza
Copy link
Collaborator

@DevSrSouza DevSrSouza commented Oct 17, 2023

Proposal API for ScreenModel scoped in Navigator. This implementation follows the current ScreenModelStore implementation, and it supports on it for Navigator ScreenModel, the custom dependencies API works as expected as well for Navigator Scoped.

Usage:

val navigator = LocalNavigator.currentOrThrow
val screenModel = navigator.rememberNavigatorScreenModel { YourScreenModel() }

For Root Navigator

val navigator = LocalNavigator.currentOrThrow
val rootNavigator = remember(navigator) { navigator.root() }
val screenModel = rootNavigator.rememberNavigatorScreenModel { YourScreenModel() }

fun Navigator.root(): Navigator {
   return if(parent == null) this
   else parent!!.root()
}
Screen.Recording.2023-10-17.at.14.07.36.mov

@osrl
Copy link
Contributor

osrl commented Oct 20, 2023

Is this same as #217 ?

@DevSrSouza
Copy link
Collaborator Author

No, the PR resolves the samething but does more things.

But the way it was done, to handle ScreenModels will not work, this I did is simpler and will work out of the box.

This does not solve the ViewModel specific case and hilt.

Base automatically changed from refactor/directly-dispose-model-store to main October 21, 2023 11:31
@DevSrSouza DevSrSouza force-pushed the feat/navigator-scoped-screenmodel branch from f9029ea to e8a32c9 Compare October 21, 2023 17:01
@DevSrSouza DevSrSouza merged commit 626e4cb into main Oct 22, 2023
1 check passed
@DevSrSouza DevSrSouza deleted the feat/navigator-scoped-screenmodel branch October 22, 2023 00:19
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.

None yet

3 participants