reactiveweb
    Preparing search index...

    Class State<Value>

    State container that represents the asynchrony of a trackedFunction

    Type Parameters

    • Value
    Index

    Constructors

    Properties

    caughtError: unknown

    ember-async-data doesn't catch errors, so we can't rely on it to protect us from "leaky errors" during rendering.

    See also: https://github.com/qunitjs/qunit/issues/1736

    data: null | TrackedAsyncData<Value> = null
    promise: Value

    Accessors

    • get error(): null | {}

      When the function passed to trackedFunction throws an error, that error will be the value returned by this property

      Returns null | {}

    • get isError(): boolean

      Alias for isRejected

      Returns boolean

    • get isFinished(): boolean

      Alias for isResolved || isRejected

      Returns boolean

    • get isLoading(): boolean

      Alias for isPending

      Returns boolean

    • get isPending(): boolean

      Initially true, and remains true until the underlying promise resolves or rejects.

      Returns boolean

    • get isRejected(): boolean

      When true, the function passed to trackedFunction has errored

      Returns boolean

    • get isResolved(): boolean

      When true, the function passed to trackedFunction has resolved

      Returns boolean

    • get isSettled(): boolean

      Alias for isFinished which is in turn an alias for isResolved || isRejected

      Returns boolean

    • get state(): "PENDING" | "RESOLVED" | "REJECTED" | "UNSTARTED"

      Returns "PENDING" | "RESOLVED" | "REJECTED" | "UNSTARTED"

    • get value(): null | Awaited<Value>

      this.data may not exist yet.

      Additionally, prior iterations of TrackedAsyncData did not allow the accessing of data before .state === 'RESOLVED' (isResolved).

      From a correctness standpoint, this is perfectly reasonable, as it forces folks to handle the states involved with async functions.

      The original version of trackedFunction did not use TrackedAsyncData, and did not have these strictnesses upon property access, leaving folks to be as correct or as fast/prototype-y as they wished.

      For now, trackedFunction will retain that flexibility.

      Returns null | Awaited<Value>

    Methods

    • Parameters

      • __namedParameters: CallbackMeta

      Returns Promise<undefined | Value>

    • Returns Promise<void>

    • Will re-invoke the function passed to trackedFunction this will also re-set some properties on the State instance. This is the same State instance as before, as the State instance is tied to the fn passed to trackedFunction

      error or resolvedValue will remain as they were previously until this promise resolves, and then they'll be updated to the new values.

      Returns Promise<void>