Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BasicRouter

Hierarchy

Implements

  • INotify

Index

Constructors

constructor

Properties

config

config: RouterConfig

current

current: undefined | RouteMatch

Methods

addListener

  • addListener(id: string, fn: Listener, scope?: any): boolean
  • {@inheritDoc @thi.ng/api#INotify.addListener}

    Parameters

    • id: string
    • fn: Listener
    • Optional scope: any

    Returns boolean

format

  • format(id: string, params?: any, hash?: boolean): string
  • format(match: Partial<RouteMatch>, hash?: boolean): string
  • Returns a formatted version of given RouteMatch, incl. any params. Throw an error if an invalid route id is provided.

    Parameters

    • id: string
    • Optional params: any

      -

    • Optional hash: boolean

      if true, prepends # to results

    Returns string

  • Parameters

    Returns string

Protected handleRouteFailure

  • handleRouteFailure(): boolean

Protected matchRoute

Protected matchRoutes

notify

  • notify(event: Event): void

removeListener

  • removeListener(id: string, fn: Listener, scope?: any): boolean
  • {@inheritDoc @thi.ng/api#INotify.removeListener}

    Parameters

    • id: string
    • fn: Listener
    • Optional scope: any

    Returns boolean

route

  • Main router function. Attempts to match given input string against all configured routes. If none matches, falls back to default route. Before returning, triggers event with return value as well.

    Parameters

    • src: string

    Returns undefined | RouteMatch

routeForID

  • routeForID(id: string): undefined | Route

start

  • start(): void

Protected validateRouteParams

Generated using TypeDoc