Class: Router

routing~Router()

A bare-bones history-api based SPA router.

Constructor

new Router()

Initialize the router and determine the current page.
Source:

Members

base_path

Returns the APP_BASE_PATH of the application.
Source:

current_route

The currently navigated route.
Source:

history :Array.<object>

Array of router history records.
Type:
  • Array.<object>
Source:

route_args :undefined|*

Arguments for the current route.
Type:
  • undefined | *
Source:

subscribers :Array.<function()>

List of callback functions listening for route changes.
Type:
  • Array.<function()>
Source:

Methods

back()

Navigate back one route.
Source:

build_url(…parts) → {string}

Given an array of route parts, build a joined URL route.
Parameters:
Name Type Attributes Description
parts string <repeatable>
Source:
Returns:
Type
string
Navigate the app to the given path with the given args.
Parameters:
Name Type Description
path string
args *
Source:

subscribe(handler) → {object}

Subscribe to listen for route changes. Returns an object with an unsubscribe() property.
Parameters:
Name Type Description
handler function callback called when the route changes
Source:
Returns:
- subscription manager
Type
object