@kayahr/signal
    Preparing search index...

    Function createResource

    • Creates a reactive async resource and returns a value getter together with status and control methods.

      The resource eagerly loads from the current source value and reloads whenever the source changes or resource.reload() is called. Concurrent loads are cancelled through an abort signal and stale results are ignored. The returned resource object can be manually disposed manually.

      Type Parameters

      • S
      • T

      Parameters

      • source: Getter<S>

        Getter providing the current load source.

      • load: ResourceLoader<S, T>

        Loads the resource value for the current source.

      • Optionaloptions: CreateResourceOptions<T, never, S> & { initialValue?: undefined }

        Optional resource behavior overrides without an explicit initial value.

      Returns [Getter<T | undefined>, Resource]

      A resource value getter and a resource controller object.

    • Creates a reactive async resource and returns a value getter together with status and control methods.

      The resource eagerly loads from the current source value and reloads whenever the source changes or resource.reload() is called. Concurrent loads are cancelled through an abort signal and stale results are ignored. The returned resource object can be manually disposed manually.

      Type Parameters

      • S
      • T
      • Init

      Parameters

      • source: Getter<S>

        Getter providing the current load source.

      • load: ResourceLoader<S, T>

        Loads the resource value for the current source.

      • options: CreateResourceOptions<T, Init, S> & { initialValue: Init }

        Optional resource behavior overrides with an explicit initial value.

      Returns [Getter<T | Init>, Resource]

      A resource value getter and a resource controller object.