Class Resolver<T, R, C>

Type Parameters

  • T = unknown
  • R extends object = EmptyObject
  • C extends object = EmptyObject

Hierarchy (view full)

Constructors

Properties

baseUrl: string

The base URL for all routes in the router instance. By default, if the base element exists in the <head>, vaadin-router takes the <base href> attribute value, resolved against the current document.URL.

errorHandler?: ErrorHandlerCallback<T>
resolveRoute: ResolveRouteCallback<T, R, C>

Accessors

  • get __effectiveBaseUrl(): string
  • If the baseUrl property is set, transforms the baseUrl and returns the full actual base string for using in the new URL(path, base); and for prepernding the paths with. The returned base ends with a trailing slash.

    Otherwise, returns empty string.

    Returns string

Methods

  • If the baseUrl is set, matches the pathname with the router’s baseUrl, and returns the local pathname with the baseUrl stripped out.

    If the pathname does not match the baseUrl, returns undefined.

    If the baseUrl is not set, returns the unmodified pathname argument.

    Parameters

    • pathname: string

    Returns undefined | string

  • Appends one or several routes to the routing config and returns the effective routing config after the operation.

    Parameters

    • routes: Route<T, R, C> | readonly Route<T, R, C>[]

      a single route or an array of those (the array is shallow copied)

    Returns readonly Route<T, R, C>[]

  • Returns the current list of routes (as a shallow copy). Adding / removing routes to / from the returned array does not affect the routing config, but modifying the route objects does.

    Returns readonly Route<T, R, C>[]

  • Removes all existing routes from the routing config.

    Returns void

  • Asynchronously resolves the given pathname, i.e. finds all routes matching the pathname and tries resolving them one after another in the order they are listed in the routes config until the first non-null result.

    Returns a promise that is fulfilled with the return value of an object that consists of the first route handler result that returns something other than null or undefined and context used to get this result.

    If no route handlers return a non-null result, or if no route matches the given pathname the returned promise is rejected with a 'page not found' Error.

    Parameters

    • pathnameOrContext: string | ResolveContext<C>

      the pathname to resolve or a context object with a pathname property and other properties to pass to the route resolver functions.

    Returns Promise<ActionResult<RouteContext<T, R, C>>>

  • Sets the routing config (replacing the existing one).

    Parameters

    • routes: Route<T, R, C> | readonly Route<T, R, C>[]

      a single route or an array of those (the array is shallow copied)

    Returns object