Belin.io Core
    Preparing search index...

    Class Router

    Performs location-based routing using a configuration of URL patterns and associated render callbacks.

    Hierarchy

    • Router
      • Router
    Index

    Constructors

    • Creates a new router.

      Parameters

      • host: HTMLElement & ReactiveControllerHost

        The host element.

      • routes: RouteConfig[]

        The routing table.

      • options: Partial = {}

        The router options.

      Returns Router

    Properties

    fallback?: BaseRouteConfig

    A default fallback route which will always be matched if none of the routes match. Implicitly matches to the path "/*".

    routes: RouteConfig[]

    Accessors

    • get params(): { [key: string]: undefined | string }

      The current parsed route parameters.

      Returns { [key: string]: undefined | string }

    Methods

    • Moves back one route in the session history.

      Parameters

      • fallbackRoute: string = ""

        A fallback route which will be used if the session history is empty.

      Returns void

    • Navigates to the specified route.

      Parameters

      • route: string

        The route to navigate.

      • options: { push?: boolean } = {}

        Value indicating whether to add the route to the session history.

      Returns Promise<void>

      Resolves when the router has navigated to the specified route.

    • Returns void

    • Returns void

    • Returns a URL string of the current route, including parent routes, optionally replacing the local path with pathname.

      Parameters

      • Optionalpathname: string

      Returns string

    • Registers a function that will be invoked whenever the navigate event is triggered.

      Parameters

      • listener: (event: RouterEvent) => void

        The event handler to register.

      Returns this

      This instance.

    • The result of calling the current route's render() callback.

      Returns unknown