BurkusCat / Burkus.Mvvm.Maui

A simple MVVM framework for .NET MAUI. It provides: navigation, lifecycle events, parameter passing, native dialog abstractions, and testability.
MIT License
25 stars 5 forks source link

[Feature] Navigation results #3

Open BurkusCat opened 11 months ago

BurkusCat commented 11 months ago

Is your feature request related to a problem? Please describe. When navigating to a page, it doesn't always happen successfully. It would be good if the page/service performing the navigation, was able to handle the result.

Describe the solution you'd like The navigation service methods could be updated to return Task<NavigationResult>. The result can be ignored if the caller wishes e.g.

await navigationService.Push(...);
_ = await navigationService.Push(...);

Does the first line in the example above generate any warnings in compiler?

Describe alternatives you've considered Try/catches on calls to navigation service.

Proposed APIs If possible, try to propose how the API might look. For example:

// NavigationResult
public bool IsSuccess { get; }

public Exception Exception { get; }

Additional context It is probably a good idea to support two different styles of error handling. This new method is one of them, another way is allowing any failed navigation to throw exceptions instead of returning a result.

Builder configuration: ThrowOnNavigationFailure, instead of catching a navigation exception and returning a result, it should rethrow the exception