Added new result awaiting and setting ViewModel navigation #4848
+477
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Adds new
IMvxResultAwaitingViewModel<TResult>
andIMvxResultSettingViewModel<TResult>
interfaces and corresponding abstract classes to create a result navigation contract between the awaiting and setting the result ViewModels. Under the hood it uses a newIMvxResultViewModelManager
that registers, unregisters and sets the result to the registered result awaiting ViewModels.It's better to use predefined abstract classes
MvxResultAwaitingViewModel<TResult>
,MvxMultiResultAwaitingViewModel<TResult1, TResult2>
,MvxResultSettingViewModel<TResult>
,MvxNavigationResultAwaitingViewModel<TResult>
,MvxNavigationResultSettingViewModel<TResult>
, and their overloads with parameters. Because when implementingIMvxResultAwaitingViewModel<TResult>
andIMvxResultSettingViewModel<TResult>
manually it requires implementing ViewModels registering, saving, restoring, unregistering, and setting the result manually as well.No navigation with awaiting the result.
🆕 What is the new behavior (if this is a feature change)?
Navigation with awaiting the result that also survives Android restoration.
💥 Does this PR introduce a breaking change?
No.
🐛 Recommendations for testing
Fragment
on bottomFragment
on bottom.Fragment
.You can test this with any dangerous permissions.
Developer option "Don't keep activities" works differently - it does not shut down the app. Though the feature also works in this case.
For other platforms it just works without restoration issues.
📝 Links to relevant issues/docs
PRs: #4312 #4652
Issues: #3342 #3980 #4230 #4262 #4553 #4651
🤔 Checklist before submitting
🧠 Extra
I am open for discussing changes for the implementation.
Here are some ideas: