variable / @typed/navigation

BeforeNavigationEvent

Describes the pre-commit event presented to navigation guards.

Package version
1.0.0-beta.7
Category
Navigation event schemas
Since
1.0.0

Import

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

Signatures

export declare const BeforeNavigationEvent: Schema.Struct<{
    readonly type: Schema.Union<readonly [
        Schema.Literal<"push">,
        Schema.Literal<"replace">,
        Schema.Literal<"reload">,
        Schema.Literal<"traverse">
    ]>;
    readonly from: Schema.Struct<{
        readonly id: Schema.String;
        readonly key: Schema.String;
        readonly url: Schema.URLFromString;
        readonly state: Schema.Unknown;
        readonly sameDocument: Schema.Boolean;
    }>;
    readonly delta: Schema.Int;
    readonly to: Schema.Struct<{
        readonly url: Schema.URLFromString;
        readonly state: Schema.Unknown;
        readonly sameDocument: Schema.Boolean;
        readonly key: Schema.optional<Schema.String>;
    }>;
    readonly info: Schema.Unknown;
}>;
export type BeforeNavigationEvent = typeof BeforeNavigationEvent.Type;

Why

Guards need the old and proposed destinations plus traversal delta before a backend mutates history. This event is deliberately distinct from post-commit {@link NavigationEvent}.

Ownership and lifetime

The schema acquires no resources. The navigation operation owns each event until its registered handlers settle; handlers must copy data they need later.

Examples

import { BeforeNavigationEvent } from "@typed/navigation/model"
import * as Schema from "effect/Schema"

const isBeforeEvent = Schema.is(BeforeNavigationEvent)

Other public imports

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

Source