Close<Result> has been removed from IMvxNavigationService
See original GitHub issue🔙 Regression
I’ve been using MvvmCross since version 7, most I worked with was version 8, lately wanted to upgrade to version 9, what was strange for me was I noticed that I can’t close the ViewModel with return of result like before, after I took a look at the source I saw only one (out of the two) versions of Close method remained and its :
Task<bool> Close(IMvxViewModel viewModel, CancellationToken cancellationToken = default);
however, the implementation still exists in MvxNavigationService
public virtual async Task<bool> Close<TResult>(
IMvxViewModelResult<TResult> viewModel, TResult result, CancellationToken cancellationToken = default)
Old (and correct) behavior
Exists:
public virtual async Task<bool> Close<TResult>(
IMvxViewModelResult<TResult> viewModel, TResult result, CancellationToken cancellationToken = default)
Current behavior
Not exists:
public virtual async Task<bool> Close<TResult>(
IMvxViewModelResult<TResult> viewModel, TResult result, CancellationToken cancellationToken = default)
Reproduction steps
bring back the above method so we can’t return the result from the closed ViewModel
Configuration
Version: 9.x
Platform:
- 📱 iOS
- 🤖 Android
- 🏁 WPF
- 🌎 UWP
- 🍎 MacOS
- 📺 tvOS
- 🐒 Xamarin.Forms
Issue Analytics
- State:
- Created 8 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
MvvmCross - Passing a string with IMvxNavigationService
Whenever trying to run, the string object 'parameter' in my TableviewController's Prepare function remains 'null' and I have no idea how to fix ......
Read more >MvvmCross 5.0 release!
Removal of deprecated plugins. MvvmCross' powerful plugin framework has brought us many good things. However, over time certain plugins have ...
Read more >IMvxNavigationService.cs - MvvmCross ...
The .NET MVVM framework for cross-platform solutions, including Xamarin.iOS, Xamarin.Android, Windows and Mac.
Read more >Navigation
MvvmCross uses ViewModel first navigation. Meaning that we navigate from ViewModel to ViewModel and not from View to View. In MvvmCross the ViewModel...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The workaround is to not use it. You have plenty of options to make something work. I.e. the Parameters for you ViewModel, you could have a callback for backwards navigation. Or you could have some kind of global state. Totally up to you how to tackle it.
Message Bus is the right way. Subscribe for your messages when a VM with a result gets created. Unsubscribe when it gets destroyed. From the VM with a result notify about it. In my projects I made special
IResultAwaitingViewModel
,IResultSettingViewModel
and extendedIMvxNavigationService
to pass those VMs and they do all the subscribing/unsubscribing logic for me.