AbstractRouter 

The basic implementation of the Router interface, providing the common or default functionality for parts of the API.

Kind: global abstract class


new AbstractRouter(pageManager, factory, dispatcher) 

Initializes the router.

Param Type Description
pageManager PageManager The page manager handling UI rendering, and transitions between pages if at the client side.
factory RouteFactory Factory for routes.
dispatcher Dispatcher Dispatcher fires events to app.

Example

router.link('article', {articleId: 1});

Example

router.redirect('http://www.example.com/web');

Example

router.add(
       'home',
       '/',
       ns.app.page.home.Controller,
       ns.app.page.home.View,
       {
         onlyUpdate: false,
         autoScroll: true,
         allowSPA: true,
         documentView: null,
         managedRootView: null,
         viewAdapter: null
       }
     );

abstractRouter._pageManager : PageManager 

The page manager handling UI rendering, and transitions between pages if at the client side.

Kind: instance property of AbstractRouter


abstractRouter._factory : RouteFactory 

Factory for routes.

Kind: instance property of AbstractRouter


abstractRouter._dispatcher : Dispatcher 

Dispatcher fires events to app.

Kind: instance property of AbstractRouter


abstractRouter._protocol : string 

The current protocol used to access the application, terminated by a colon (for example https:).

Kind: instance property of AbstractRouter


abstractRouter._host : string 

The application’s host.

Kind: instance property of AbstractRouter


abstractRouter._root : string 

The URL path pointing to the application’s root.

Kind: instance property of AbstractRouter


abstractRouter._languagePartPath : string 

The URL path fragment used as a suffix to the _root field that specifies the current language.

Kind: instance property of AbstractRouter


abstractRouter._routes : Map.<string, Route> 

Storage of all known routes. The key are the route names.

Kind: instance property of AbstractRouter


abstractRouter.init() 

Kind: instance method of AbstractRouter


abstractRouter.add() 

Kind: instance method of AbstractRouter


abstractRouter.remove() 

Kind: instance method of AbstractRouter


abstractRouter.getPath() 

Kind: instance method of AbstractRouter


abstractRouter.getUrl() 

Kind: instance method of AbstractRouter


abstractRouter.getBaseUrl() 

Kind: instance method of AbstractRouter


abstractRouter.getDomain() 

Kind: instance method of AbstractRouter


abstractRouter.getHost() 

Kind: instance method of AbstractRouter


abstractRouter.getProtocol() 

Kind: instance method of AbstractRouter


abstractRouter.getCurrentRouteInfo() 

Kind: instance method of AbstractRouter


abstractRouter.listen() 

Kind: instance abstract method of AbstractRouter


abstractRouter.redirect() 

Kind: instance abstract method of AbstractRouter


Kind: instance method of AbstractRouter


abstractRouter.route() 

Kind: instance method of AbstractRouter


abstractRouter.handleError() 

Kind: instance method of AbstractRouter


abstractRouter.handleNotFound() 

Kind: instance method of AbstractRouter


abstractRouter.isClientError() 

Kind: instance method of AbstractRouter


abstractRouter.isRedirection() 

Kind: instance method of AbstractRouter


abstractRouter._extractRoutePath(path) ⇒ string 

Strips the URL path part that points to the application’s root (base URL) from the provided path.

Kind: instance method of AbstractRouter
Returns: string - URL path relative to the application’s base URL.
Access: protected

Param Type Description
path string Relative or absolute URL path.

abstractRouter._handle(route, params, options, [action]) ⇒ Promise.<Object.<string, \*>> 

Handles the provided route and parameters by initializing the route’s controller and rendering its state via the route’s view.

The result is then sent to the client if used at the server side, or displayed if used as the client side.

Kind: instance method of AbstractRouter
Returns: Promise.<Object.<string, \*>> - A promise that resolves when the page is rendered and the result is sent to the client, or displayed if used at the client side.

Param Type Description
route Route The route that should have its associated controller rendered via the associated view.
params Object.<string, (Error\|string)> Parameters extracted from the URL path and query.
options Object The options overrides route options defined in the routes.js configuration file.
[action] Object An action object describing what triggered this routing.

abstractRouter._getRouteByPath(path) ⇒ Route 

Returns the route matching the provided URL path part. The path may contain a query.

Kind: instance method of AbstractRouter
Returns: Route - The route matching the path, or null if no such route exists.

Param Type Description
path string The URL path.

abstractRouter._getCurrentlyRoutedPath() ⇒ string 

Returns path that is stored in private property when a route method is called.

Kind: instance method of AbstractRouter