Class Router

Router class

See

router

Hierarchy

Constructors

Properties

debug: boolean = false
defaultRoute?: Function
loadedPath: string = ""
params: string[] = []
routes: Route[] = []
suspendEvent: boolean = false

Methods

  • Add a route

    The first matching route will be executed

    Parameters

    • re: RegExp | RouterMethod

      eg. /^notes/(.*)$/

    • Optional handler: RouterMethod

      Is called with the arguments matched in the route regexp. May return Promise so the router start() promise will resolve when this promise is resolved.

    Returns Router

    Example

    go.Router.add(/^([a-zA-Z0-9]*)/([\d]*)$/, (entity:string, id:string) => {

    });
  • Fire an event

    When a listener returns false this function will return false too.

    Type Parameters

    • K extends "change"

    Parameters

    Returns boolean

  • Get the parameters evaluated from the router path

    Returns string[]

  • Get the router path

    Returns string

  • Go to the give router path

    Parameters

    • path: string

    Returns Promise<unknown>

    Promise

  • Parameters

    • handler: Function
    • match: string[]
    • oldPath: string

    Returns Promise<any>

  • Reload current page.

    Returns void

  • Set route path without executing matching routes.

    Parameters

    • path: string

    Returns void

  • Start the router and run the matching route handlers

    Returns Promise<void>

Generated using TypeDoc