Skip to content

Commit

Permalink
docs: HowTo IRouteNotifier
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Sep 9, 2024
1 parent e5fcb78 commit 1ca8980
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions doc/Learn/Navigation/Advanced/HowTo-IRouteNotifier.md
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 -->

0 comments on commit 1ca8980

Please sign in to comment.