Options
All
  • Public
  • Public/Protected
  • All
Menu

Keeps track of whether something is loading, whether something has taken a while, and also if an error occurred

Type parameters

  • V = unknown

Hierarchy

  • LoadingState

Index

Constructors

constructor

Properties

Private Readonly delay

delay: number

Optional error

error: unknown

The error, if any occurred while running

Private Optional loadingPromise

loadingPromise: undefined | Promise<V>

Private Readonly messages

messages: { invalidItemWarning: (value: unknown) => string; loaderError: (error: string) => string; missingItemsWarning: (value: unknown) => string; nilValueWarning: () => string }

Type declaration

  • invalidItemWarning: (value: unknown) => string
      • (value: unknown): string
      • Parameters

        • value: unknown

        Returns string

  • loaderError: (error: string) => string
      • (error: string): string
      • Parameters

        • error: string

        Returns string

  • missingItemsWarning: (value: unknown) => string
      • (value: unknown): string
      • Parameters

        • value: unknown

        Returns string

  • nilValueWarning: () => string
      • (): string
      • Returns string

status

status: LoadingStatus = "idle"

Accessors

isDelayed

  • get isDelayed(): boolean

isFinished

  • get isFinished(): boolean

isLoading

  • get isLoading(): boolean

Methods

run

  • run(block: () => Promise<V>): Promise<undefined | V>
  • Run an async action. If this is called while an action is already loading, waits until the current action is finished.

    If we need some other behavior later (e.g. cancelling the current action, or queueing it), we can add options or make new methods

    Parameters

    • block: () => Promise<V>
        • (): Promise<V>
        • Returns Promise<V>

    Returns Promise<undefined | V>

Generated using TypeDoc