Provides management of a single Promise that can be shared and accessed across JS & Svelte components. This allows a Promise to be created and managed as part of the TRL application lifecycle and accessed safely in various control flow scenarios. When resolution of the current managed Promise starts further interaction is prevented.

Note: to enable debugging / log statements set the static logging variable to true.

Constructors

Accessors

  • get isActive(): boolean
  • Returns boolean

    Whether there is an active managed Promise.

  • get isProcessing(): boolean
  • Returns boolean

    Whether there is an active managed Promise and resolution is currently being processed.

  • get logging(): boolean
  • Returns boolean

    Whether global logging is enabled.

  • set logging(logging): void
  • Sets global logging enabled state.

    Parameters

    • logging: boolean

      New logging enabled state.

    Returns void

Methods

  • Resolves any current Promise with undefined and creates a new current Promise.

    Type Parameters

    • T

    Parameters

    • Optionalopts: {
          reuse?: boolean;
      }

      Options.

      • Optionalreuse?: boolean

        When true if there is an existing live Promise it is returned immediately.

    Returns Promise<T>

    The new current managed Promise.

  • Gets the current Promise if any.

    Returns Promise<any>

    Current Promise.

  • Rejects the current Promise if applicable.

    Parameters

    • Optionalresult: any

      Result to reject.

    Returns boolean

    Was the promise rejected.

  • Resolves the current Promise if applicable.

    Parameters

    • Optionalresult: any

      Result to resolve.

    Returns boolean

    Was the promise resolved.