# `Plushie.Route`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.6.0/lib/plushie/route.ex#L1)

Client-side routing for multi-view apps. Pure data structure
maintaining a navigation stack of `{path, params}` entries.

The stack is last-in-first-out. `push/3` adds a new entry on top;
`pop/1` removes the top entry (never pops the last one). `current/1`
and `params/1` read from the top of the stack.

## Example

    route = Plushie.Route.new(:home)
    route = Plushie.Route.push(route, :settings, %{tab: "general"})
    Plushie.Route.current(route)
    #=> :settings
    Plushie.Route.params(route)
    #=> %{tab: "general"}
    route = Plushie.Route.pop(route)
    Plushie.Route.current(route)
    #=> :home

# `entry`

```elixir
@type entry() :: {term(), map()}
```

A navigation stack entry: `{path, params}`.

# `t`

```elixir
@type t() :: %Plushie.Route{stack: [entry()]}
```

# `can_go_back?`

```elixir
@spec can_go_back?(route :: t()) :: boolean()
```

Returns `true` if there is more than one entry on the stack.

# `current`

```elixir
@spec current(route :: t()) :: term()
```

Returns the current (top) path.

# `history`

```elixir
@spec history(route :: t()) :: [term()]
```

Returns a list of all paths in the stack, most recent first.

# `new`

```elixir
@spec new(initial_path :: term(), params :: map()) :: t()
```

Creates a new route with `initial_path` at the bottom of the stack.

`params` defaults to an empty map.

# `params`

```elixir
@spec params(route :: t()) :: map()
```

Returns the params associated with the current (top) path.

# `pop`

```elixir
@spec pop(route :: t()) :: t()
```

Pops the top entry from the stack. Returns the route unchanged if
only one entry remains (the root is never popped).

# `push`

```elixir
@spec push(route :: t(), path :: term(), params :: map()) :: t()
```

Pushes a new `path` (with optional `params`) onto the navigation stack.

# `replace_top`

```elixir
@spec replace_top(route :: t(), path :: term(), params :: map()) :: t()
```

Replaces the top entry with a new `path` and `params`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
