Method NavigateAsync
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
NavigateAsync(string, NavigationMode, CancellationToken)
Navigates to the given path. Evaluation order is Blocker -> Guard -> Loader: the Blocker is asked before the path is matched, and a Guard's redirect is not put to it. A successful Guard redirect records the final target rather than intermediate targets while preserving the originating navigation's history effect. At most four redirects are followed: a fifth is refused and the navigation ends with Error.
public VelvetTask<NavigationResult> NavigateAsync(string path, NavigationMode mode = NavigationMode.Push, CancellationToken cancellationToken = default)
Parameters
pathstringTarget path to navigate to.
modeNavigationModeHow the destination is recorded in the history stack. Defaults to Push. Back and Forward step onto the neighbouring entry, whose own location is committed:
pathis not read for them.cancellationTokenCancellationTokenToken forwarded to Loaders.
Returns
- VelvetTask<NavigationResult>
A NavigationResult indicating the outcome: Success on completion, NotFound when no route matches, after committing the 404 that Errors carries as an ErrorResponse (and when
pathis null, which commits nothing), Blocked when a Blocker rejects the attempt, Cancelled when concurrent navigation or the cancellation token aborts it, when it is asked of a router already disposed, or whenmodeis Back / Forward and the history has no entry to step onto, or Error on redirect overflow.
NavigateAsync(string, NavigationMode, int, CancellationToken)
Navigates with relative resolution anchored to a specific matched-route level
(baseRouteIndex), so a .. is interpreted relative to the route the
caller is rendered in rather than the leaf route. UseNavigate/V.Navigate pass the
caller's Outlet depth here so a relative target anchors at the caller's route level;
-1 falls back to the leaf route.
public VelvetTask<NavigationResult> NavigateAsync(string path, NavigationMode mode, int baseRouteIndex, CancellationToken cancellationToken = default)
Parameters
pathstringmodeNavigationModebaseRouteIndexintcancellationTokenCancellationToken
Returns
NavigateAsync(string, NavigateOptions?, int, CancellationToken)
Navigates as React Router's navigate(to, options) does: options chooses
push or replace, the State the new entry carries, and whether a relative
path resolves against the route hierarchy or the URL. A fragment in
path lands in Hash; a target that is only a
fragment keeps the current path and drops its query, as React Router resolves it.
public VelvetTask<NavigationResult> NavigateAsync(string path, NavigateOptions? options, int baseRouteIndex = -1, CancellationToken cancellationToken = default)
Parameters
pathstringTarget path, resolved as NavigateAsync(string, NavigationMode, int, CancellationToken) resolves it.
optionsNavigateOptionsHow to navigate; null takes every default.
baseRouteIndexintThe matched-route level a route-relative target anchors at;
-1is the leaf.cancellationTokenCancellationTokenToken forwarded to Loaders.
Returns
- VelvetTask<NavigationResult>
The outcome, as NavigateAsync(string, NavigationMode, CancellationToken) reports it.
NavigateAsync(int, CancellationToken)
Moves delta entries along the history stack, as React Router's
navigate(delta) does: negative goes back, positive forward, and a delta past either end lands
on the end entry as a memory history's go does. The entry keeps the
State and Key it was created with.
public VelvetTask<NavigationResult> NavigateAsync(int delta, CancellationToken cancellationToken = default)
Parameters
deltaintEntries to move by. A delta that does not move, zero or one clamped at an end, lands on the entry already current and runs its loaders again, as the router does for the pop a memory history's
goannounces.cancellationTokenCancellationTokenToken forwarded to Loaders.
Returns
- VelvetTask<NavigationResult>
The outcome, as NavigateAsync(string, NavigationMode, CancellationToken) reports it; Cancelled when the history holds no entry.