← Navigation and routes

Navigation.EntryStack

luastra/navigation

Navigation.EntryStack is a stateful navigation contract that owns route history or translates between route entries and canonical locations. Its public methods validate mutations and return bounded results instead of exposing internal tables.

Before you use it

Add luastra/navigation to this module's dependencies in luastra.json, then import it with require("luastra/navigation"). No host capability is required for in-memory navigation. Browser URL/history synchronization additionally needs luastra/host and navigation.history.

How it fits

The type describes a route, stack, compiler, or checked result used by navigation operations.

When to use it

Use Navigation.EntryStack as long-lived application state when navigation must survive repeated renders. Create it once, mutate it through its public methods, and render from its current route rather than rebuilding it on every render.

Fields or definition

ParameterType / valuesDescription
current() -> RouteEntryCallable current member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
currentLocation() -> stringCallable currentLocation member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
canBack() -> booleanCallable canBack member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
push(entry: any) -> MutationResultCallable push member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
pushLocation(location: string) -> MutationResultCallable pushLocation member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
replace(entry: any) -> MutationResultCallable replace member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
replaceLocation(location: string) -> MutationResultCallable replaceLocation member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
back() -> booleanCallable back member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
snapshot() -> EntrySnapshotCallable snapshot member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
encode() -> stringCallable encode member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
restore(snapshot: any) -> RestoreResultCallable restore member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.
restoreEncoded(value: string) -> RestoreResultCallable restoreEncoded member exposed by Navigation.EntryStack; invoke it through the owning contract rather than replacing internal state.

What happens next

A checked route/navigation annotation.

Failures and fixes

Invalid definitions, unknown routes, malformed parameters, excessive history depth, or incompatible snapshots return bounded errors or fail construction. Navigation result records use success:boolean with optional fields, so verify the field you need after checking success.

Availability

Public-source alpha API in 0.5.0-alpha; URL integration is a separate host capability.

Exact declaration

export type EntryStack = {
    current: () -> RouteEntry,
    currentLocation: () -> string,
    canBack: () -> boolean,
    push: (entry: any) -> MutationResult,
    pushLocation: (location: string) -> MutationResult,
    replace: (entry: any) -> MutationResult,
    replaceLocation: (location: string) -> MutationResult,
    back: () -> boolean,
    snapshot: () -> EntrySnapshot,
    encode: () -> string,
    restore: (snapshot: any) -> RestoreResult,
    restoreEncoded: (value: string) -> RestoreResult,
}

Continue learning

Prerequisites

Navigation.RouteEntry

Companions

Navigation.RouteCompilerNavigation.compile

Next steps

Navigation.createRouter

Complete inventory

View all pages in Navigation and routes
← Previous: Navigation.MutationResultNext: Navigation.decideBack →