Home Reference Source
private class | source

Router

Direct Subclass:

HashRouter, HistoryRouter

Router

This subclass must override depart() and go(path)

Example:

const routeMap = {
  index: HomeView,                  // /
  about: AboutView,                 // /about
  books: {
    index: BookListView,            // /books/
    ':bookId': {
      index: BookDetailView,        // /books/:bookId
      summary: BookSummaryView,     // /books/:bookId/summary
      readers: {
        index: '../',   // redirect to /books/:bookId
        ':readerId': BookReaderView // /books/:bookId/readers/:readerId
      }
    },
    pages: {
      index: PagesView,             // /pages/
      faq: FaqView,                 // /pages/faq
      policy: PolicyView            // /pages/policy
    }
};

const router = new Router(routeMap);

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

onMove: *

Private Members
private
private

Method Summary

Public Methods
public

canGo(path: *): *

Need call depart after first page loaded

public

getRoute(absPath: *): Object

public

move(path: String)

Need call go when History mode and anchor tag clicked or moving the other page by a script

Private Methods
private

_chopEndSlash(pt: *): *

private

_isStr(v: *): *

private

_parsePath(path: *): *

private

_parseRoute(map: *): *

private

_resolve(src: *, dest: *): *

Public Constructors

public constructor() source

Public Members

public onMove: * source

Private Members

private _lastRoute: * source

private _routeTree: * source

Public Methods

public canGo(path: *): * source

Need call depart after first page loaded

depart() { }

Params:

NameTypeAttributeDescription
path *

Return:

*

public getRoute(absPath: *): Object source

Params:

NameTypeAttributeDescription
absPath *

Return:

Object

layer

Return Properties:

NameTypeAttributeDescription
view Page

page view.

ctx Object

context (path ids).

public move(path: String) source

Need call go when History mode and anchor tag clicked or moving the other page by a script

Params:

NameTypeAttributeDescription
path String

path go(path) { }

Private Methods

private _chopEndSlash(pt: *): * source

Params:

NameTypeAttributeDescription
pt *

Return:

*

private _isStr(v: *): * source

Params:

NameTypeAttributeDescription
v *

Return:

*

private _parsePath(path: *): * source

Params:

NameTypeAttributeDescription
path *

Return:

*

private _parseRoute(map: *): * source

Params:

NameTypeAttributeDescription
map *

Return:

*

private _resolve(src: *, dest: *): * source

Params:

NameTypeAttributeDescription
src *
dest *

Return:

*