variable / @typed/navigation

useBlockNavigation

Registers a scoped navigation blocker and returns renderer-independent blocking state.

Package version
1.0.0-beta.13
Category
Blocking policy
Since
1.0.0

Import

import { useBlockNavigation } from "@typed/navigation";

Signatures

export declare const useBlockNavigation: <R = never>(params?: UseBlockNavigationParams<R>) => Effect.Effect<BlockNavigation, never, Navigation | R | Scope.Scope>;

Why

Unsaved-work flows need to pause navigation without replacing the provider or forcing state into a UI component. At most one transition is outstanding; later attempts are not independently queued.

Ownership and lifetime

The required Scope owns the before-navigation registration, RefSubject, and deferred settlement. Scope closure cancels an outstanding transition and finalizes the registration. Consumers must observe and settle the returned state inside that owning Scope.

Examples

import { useBlockNavigation } from "@typed/navigation/Blocking"
import * as Effect from "effect/Effect"

const blocker = useBlockNavigation({ shouldBlock: () => Effect.succeed(true) })

Scope behavior follows Effect v4 resource management: https://effect.website/docs/resource-management/scope/.

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source