plushie/route

Stack-based navigation for multi-page apps.

Each entry is a path with associated params. The stack is LIFO; the bottom entry (root) can never be popped.

Types

A navigation route stack.

pub opaque type Route

Values

pub fn can_go_back(route: Route) -> Bool

Check if navigation can go back (more than root entry).

pub fn current(route: Route) -> String

Get the current path.

pub fn history(
  route: Route,
) -> List(#(String, dict.Dict(String, String)))

Get the full navigation history (newest first).

pub fn new(path: String) -> Route

Create a new route with an initial path.

pub fn new_with_params(
  path: String,
  params: dict.Dict(String, String),
) -> Route

Create a new route with initial path and params.

pub fn params(route: Route) -> dict.Dict(String, String)

Get the current path’s params.

pub fn pop(route: Route) -> Route

Pop the current path. Never pops the root entry.

pub fn push(route: Route, path: String) -> Route

Push a new path onto the navigation stack.

pub fn push_with_params(
  route: Route,
  path: String,
  params: dict.Dict(String, String),
) -> Route

Push a new path with params.

Search Document