compose-destinations
compose-destinations copied to clipboard
Feature request: Allow generation of SavedStateHandle from NavArgs for testing
In our current implementation (without destinations) we test our ViewModels constructing with a SavedStateHandle from a specific navArg in the following way:
val viewModel = XViewModel(
savedStateHandle = FragmentXArgs(...).toSavedStateHandle()
)
the .toSavedStateHandle()
method is generated by the Google navigation library.
I bet there is a similar method being generated under the hood for this project, so it would be great if we could also use it for creating an initial SavedStateHandle to be used in our tests.
Is this already on the roadmap? Or is it already implemented but I couldn't find it?
Hi @JWvanV !
We discussed this here too: https://github.com/raamcosta/compose-destinations/issues/344
I believe hilt recently added changes to improve assisted injection, so injecting the arguments class directly may be easier now.
That said, I will investigate what would take to do this and report my findings here. Thanks for reporting! 🙏
Good news: implemented this today for v2.
V2 is already delayed considering I wanted to release it Q4 last year, but hopefully it will be Q1 this year instead 🤞
Awesome!! Really looking forward to V2. I also have a suggestion of the result recipient lambda, but I'll create a new issue for that :)