new Router(params) → {Router}
Create a Router. Only one Router instance will be created in an application.
Listens to browser location changes and fires when a known route is matched.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
params |
Object |
Properties
|
Fires:
Returns:
singleton
- Type
- Router
Methods
add(params)
Parameters:
Name | Type | Description |
---|---|---|
params |
Router~Route | A Route object |
navigate(params)
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
Properties
|
Type Definitions
Route
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
pathname |
string | The url pathname that will trigger this route (eg. /search/:query). |
name |
string | A name for this route. |
listener |
function | The callback function for when this route is triggered. |
Events
router:execute
Fired when a matching route is found.
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
pathname |
string | The matched pathname. |
name |
string | A matched name. |
|
Array.<function()> | Array of matched listeners. |
router:nomatch
Fired when no matching route is found.
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
pathname |
string | The pathname that did not have a match. |