Home Reference Source
import {Router} from 'arva-js/core/Router.js'
public class | source

Router

Extends:

eventemitter3~EventEmitter → Router

Direct Subclass:

ArvaRouter

Abstract Router class which can be implemented to be used in an MVP setup.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

add(route: String, handler: Function): void

Registers a single controller.

public

go(controller: Controller | Function | String, method: String, params: Object): void

Triggers navigation to one of the controllers

public

On a route change, calls the corresponding controller method with the given parameter values.

public

setDefault(controller: Controller | Function | String, method: String): void

Sets the initial controller and method to be activated whenever the controllers are activated.

Public Constructors

public constructor source

Public Members

public controllers: * source

public defaultController: string source

public defaultMethod: string source

Public Methods

public add(route: String, handler: Function): void source

Registers a single controller.

Params:

NameTypeAttributeDescription
route String

Route to trigger handler on.

handler Function

Method to call on given route.

Return:

void

public go(controller: Controller | Function | String, method: String, params: Object): void source

Triggers navigation to one of the controllers

Params:

NameTypeAttributeDescription
controller Controller | Function | String

The controller instance, controller constructor, or controller name to go to.

method String

The method to call in given controller.

params Object

Dictonary of key-value pairs containing named arguments (i.e. {id: 1, test: "yes"})

Return:

void

public run(): Boolean source

On a route change, calls the corresponding controller method with the given parameter values.

Return:

Boolean

Whether the current route was successfully ran.

public setDefault(controller: Controller | Function | String, method: String): void source

Sets the initial controller and method to be activated whenever the controllers are activated.

Params:

NameTypeAttributeDescription
controller Controller | Function | String

Default controller instance, controller constructor, or controller name to go to.

method String

Default method to call in given controller.

Return:

void