Comments (3)
Hi 👋
If you're always expecting the same type of arguments (in the example you used InitialData
), then you can create the ViewModel in the place where you are creating your NavGraphViewModelStoreOwner
.
Your screen can then receive the VM already created. Note that you have access to the navigation arguments in the dependenciesContainerBuilder
.
from compose-destinations.
Thanks, that's through the navArgs
field right? and they'll have to be cast from Any to the destination's NavArg type?
from compose-destinations.
Yes. Although now that you mention it, at least for specific destinations, I could do better (so expect this on next lib versions):
destination(ProfileScreenDestination) { // this: DependenciesContainerBuilder<ProfileScreenNavArgs>
val args: ProfileScreenNavArgs = navArgs // will compile just fine!
dependency(viewModel<ProfileViewModel>())
}
For now though:
destination(ProfileScreenDestination) { // this: DependenciesContainerBuilder<*>
val args: ProfileScreenNavArgs = navArgs as ProfileScreenNavArgs
dependency(viewModel<ProfileViewModel>())
}
from compose-destinations.
Related Issues (20)
- Multiple Backstacks HOT 1
- [Improvement] moduleName could be automatically raname to "main" HOT 1
- Multiple NavGraphs with shared routes on V2 HOT 1
- Multiple DestinationsNavHost
- upgraded from 2.0.0-beta02 to 2.0.0-beta09 HOT 16
- Crash when using Parcelable class as navigation argument HOT 6
- [KSP] Destinations generation issue HOT 1
- Standalone Sealed Classes as NavArgs in Android HOT 5
- Could not find Navigator with name "BottomSheetNavigator". You must call NavController.addNavigator() for each navigation type HOT 5
- Handle different scheme for debug and release build HOT 1
- Deeplink to nested graph destination not working HOT 2
- Build failed: Only safe or non-null asserted calls are allowed for custom `@NavTypeSerializer` HOT 3
- Destination argument names instead of values are passed when values are null HOT 6
- (Open)ResultRecipient seems to cause recompositions HOT 1
- Pass/Access ContentPadding in Child-Destinations HOT 1
- Original Question: Is this project (basically) dead? Answer: Definitely not! Exciting things are coming! HOT 2
- Could not find navigator with name "BottomSheetNavigator" Using compose 1.7 HOT 1
- Please updrade Navigation to 2.8.0-beta05,this version fixed navhost transition stuck issue. HOT 1
- DestinationsNavHost 'start' parameter ruins Multiple Back Stack HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-destinations.