generated from unoplatform/template
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5fcb78
commit 1ca8980
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
uid: Uno.Extensions.Navigation.Advanced.IRouteNotifier | ||
--- | ||
# How-To: Use IRouteNotifier to Handle Route Changes | ||
|
||
The `IRouteNotifier` interface allows you to track and respond to route changes through the `RouteChanged` event. This guide will show you how to use `IRouteNotifier` to handle route changes and improve your app's navigation. | ||
|
||
## Step-by-steps | ||
|
||
> [!IMPORTANT] | ||
> This guide assumes you used the template wizard or `dotnet new unoapp` to create your solution. If not, it is recommended that you follow the [Creating an application with Uno.Extensions article](xref:Uno.Extensions.HowToGettingStarted) for creating an application from the template. | ||
### How to Use `IRouteNotifier` to Monitor Route Changes | ||
|
||
The `IRouteNotifier` provides an effective way to monitor and respond to route changes within your application. To begin using `IRouteNotifier`, ensure your class has access to an instance of an `IRouteNotifier` implementation. Add a parameter of type `IRouteNotifier` to the constructor of your class where you want to monitor route changes. | ||
|
||
```csharp | ||
public class MyClass | ||
{ | ||
private readonly IRouteNotifier _notifier; | ||
|
||
public MyClass(IRouteNotifier notifier) | ||
{ | ||
_notifier = notifier; | ||
_notifier.RouteChanged += RouteChanged; | ||
} | ||
|
||
private async void RouteChanged(object? sender, RouteChangedEventArgs e) | ||
{ | ||
// Implement your logic to handle route change here | ||
} | ||
} | ||
``` | ||
|
||
<!-- TODO: Add IRouteNotifier, NavigationResponse, INavigator usage example --> |