question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 8 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Cheesebaroncommented, Jan 20, 2023

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.

0reactions
entdarkcommented, Aug 8, 2023

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 extended IMvxNavigationService to pass those VMs and they do all the subscribing/unsubscribing logic for me.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found