Method UseBlocker
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
UseBlocker(Func<NavigationAttempt, bool>, params object?[])
Conditionally blocks navigation departures (synchronous variant). Must be used inside Render() only.
public static RouteBlockerState UseBlocker(Func<NavigationAttempt, bool> shouldBlock, params object?[] deps)
Parameters
shouldBlockFunc<NavigationAttempt, bool>Predicate delegate; returning true blocks the departure.
depsobject[]Dependency array. When null, re-registers on every render.
Returns
- RouteBlockerState
The shared RouteBlockerState handle for inspecting / resolving the pending departure.
UseBlocker(Func<NavigationAttempt, CancellationToken, UniTask<bool>>, params object?[])
Conditionally blocks navigation departures (asynchronous variant). Use when integrating with asynchronous UI such as confirmation dialogs.
public static RouteBlockerState UseBlocker(Func<NavigationAttempt, CancellationToken, UniTask<bool>> shouldBlock, params object?[] deps)
Parameters
shouldBlockFunc<NavigationAttempt, CancellationToken, UniTask<bool>>Async predicate; returning true blocks the departure. The CancellationToken is cancelled on unmount.
depsobject[]Dependency array. When null, re-registers on every render.
Returns
- RouteBlockerState
The shared RouteBlockerState handle for inspecting / resolving the pending departure.