Class RouteController<Params, Data, Context>

Manages state of a route rendered in an Outlet.

Type Parameters

  • Params extends Dict = any

    Route params.

  • Data = any

    Data loaded by a route.

  • Context = any

    A router context.

Accessors

  • get data(): Data
  • The successfully loaded route data.

    Returns Data

  • get error(): any
  • The error that was thrown during component or data loading.

    Returns any

  • get status():
        | "loading"
        | "error"
        | "not_found"
        | "redirect"
        | "ready"
  • The current status of the controller:

    "loading"
    The route is being actively loaded.
    "ready"
    The route component and data were successfully loaded.
    "error"
    The route has thrown an error during rendering or from a data loader.
    "notFound"
    The route was marked as not found.
    "redirect"
    The route has requested a redirect.

    Returns
        | "loading"
        | "error"
        | "not_found"
        | "redirect"
        | "ready"

Constructors

Methods

  • Instantly aborts the pending route loading for this controller.

    Parameters

    • reason: unknown = ...

      The abort reason that is used for rejection of the loading promise.

    Returns void

  • Redirects the router to a new location.

    Parameters

    • to: string | To

      A location or a URL to redirect to.

    Returns void

  • Loads route component, sets provided data and notifies router subscribers.

    Parameters

    Returns void

  • Sets an error and notifies router subscribers.

    Parameters

    • error: any

      The error.

    Returns void

Properties

childController: null | RouteController<any, any, any> = null

A controller rendered in a nested Outlet.

params: Params

Route params.

parentController: null | RouteController<any, any, any> = null

A controller rendered in an enclosing Outlet.

promise: null | AbortablePromise<Data> = null

A promise that settles when the route loading is completed, or null if there's no loading in progress.

route: Route<any, Params, Data, Context>

The route this controller loads.

router: Router<Context>

The router that this controller belongs to.