interface / @typed/navigation

Blocking

Presents one blocked transition and the three ways its owner can settle it.

Package version
1.0.0-beta.7
Category
Blocking decisions
Since
1.0.0

Import

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

Signatures

export interface Blocking extends BeforeNavigationEvent {
    readonly cancel: Effect.Effect<Destination>;
    readonly confirm: Effect.Effect<Destination>;
    readonly redirect: (urlOrPath: string | URL, options?: NavigationNavigateOptions) => Effect.Effect<Destination>;
}

Why

Confirm, cancel, and redirect are explicit Effects so a UI cannot accidentally settle navigation merely by reading state. Only the first settlement of the active block changes it.

Ownership and lifetime

The Scope that registered the blocker owns this value’s deferred settlement. confirm resumes the original transition, cancel keeps the current destination, and redirect starts a replacement.

Property: cancel

Cancels the outstanding blocked transition.

Property: cancel: Why

Cancellation explicitly keeps the current destination and releases the deferred transition.

Property: cancel: Ownership and lifetime

Running cancel completes the owned Deferred with the current Destination and clears only this blocker instance’s outstanding transition.

Property: confirm

Confirms and resumes the outstanding blocked transition.

Property: confirm: Why

Settlement is an Effect, so merely observing blocking state cannot accidentally navigate.

Property: confirm: Ownership and lifetime

Running confirm completes the owned Deferred with the original navigation Effect. The blocker Scope keeps ownership until that Effect settles or the Scope closes.

Property: redirect

Replaces the outstanding blocked transition with another destination.

Property: redirect: Why

Blocked flows can choose a safe destination without first committing the rejected one.

Property: redirect: Ownership and lifetime

Running redirect completes the owned Deferred with a replacement navigation Effect. The original proposed transition is never committed by this settlement.

Other public imports

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

Source