Table of Contents

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

shouldBlock Func<NavigationAttempt, bool>

Predicate delegate; returning true blocks the departure.

deps object[]

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

shouldBlock Func<NavigationAttempt, CancellationToken, UniTask<bool>>

Async predicate; returning true blocks the departure. The CancellationToken is cancelled on unmount.

deps object[]

Dependency array. When null, re-registers on every render.

Returns

RouteBlockerState

The shared RouteBlockerState handle for inspecting / resolving the pending departure.