Class Supply<TResult>

Supply handle.

Represents a supply of something.

The supply can be cut off, and can inform on cutting off.

Type Parameters

  • in out TResult = void

Hierarchy

Implements

Constructors

  • Constructs new supply instance.

    Type Parameters

    • in out TResult = void

    Parameters

    Returns Supply<TResult>

Accessors

Methods

  • Registers a receiver of this supply.

    Once this supply cut off, the receiver will be informed on that, unless it is unavailable already.

    Does nothing if the given receiver is unavailable already.

    Parameters

    Returns Supply<TResult>

    this instance.

  • Makes this and another supply depend on each other.

    Calling this method is the same as calling this.needs(another).alsoOff(another).

    Parameters

    Returns Supply<TResult>

    this instance.

  • Creates derived supply depending on this one.

    Parameters

    • Optional derived: undefined

    Returns Supply<TResult>

    New derived supply instance.

  • Makes supply receiver depend on this supply.

    In contrast to alsoOff method, this one returns derived supply receiver.

    Type Parameters

    • TReceiver extends SupplyReceiver<TResult, TReceiver>

      Type of supply receiver.

    Parameters

    • derived: TReceiver

      Derived supply receiver to make dependent on this supply.

    Returns TReceiver

    Derived supply receiver.

  • Creates derived supply depending on this supply.

    If derived supply receiver specified, makes it depend on this supply.

    In contrast to alsoOff method, this one returns derived supply receiver.

    Type Parameters

    • TReceiver extends SupplyReceiver<TResult, TReceiver>

      Type of supply receiver.

    Parameters

    • derived: undefined | TReceiver

      Optional derived supply receiver to make dependent on this supply.

    Returns Supply<TResult> | TReceiver

    Derived supply receiver.

  • Parameters

    • result: TResult

    Returns Supply<TResult>

  • Parameters

    • reason: unknown

    Returns Supply<TResult>

  • Makes this supply depend on another supplier.

    Once the supplier cuts off the supply, this supply will be cut off with the same reason.

    Calling this method has the same effect as calling supplier.alsoOff(this).

    Parameters

    • supplier: Supplier<TResult>

      A supplier to make this supply depend on.

    Returns Supply<TResult>

    this instance.

  • Type Parameters

    • TReason

    Parameters

    Returns Supply<TResult>

  • Creates required supply this one depends on.

    Parameters

    • Optional required: undefined

    Returns Supply<TResult>

    New required supplier.

  • Makes this supplier require depend on another one.

    In contrast to needs method, this one returns required supply.

    Type Parameters

    • TSupplier extends Supplier<TResult, TSupplier>

      Type of required supplier.

    Parameters

    • required: TSupplier

      Optional supplier to make this one depend on.

    Returns TSupplier

    Required supplier.

  • Creates required supply this one depends on.

    If required supplier specified, makes this one depend on it.

    In contrast to needs method, this one returns required supply.

    Type Parameters

    • TSupplier extends Supplier<TResult, TSupplier>

      Type of required supplier.

    Parameters

    • required: undefined | TSupplier

      Optional supplier to make this one depend on.

    Returns Supply<TResult> | TSupplier

    Required supplier.

  • Builds a promise that will be resolved once this supply is done. This callback will be called immediately if supply is cut off already.

    Returns Promise<TResult>

    A promise that will be successfully resolved once this supply completes * successfully, or rejected with failure reason.

  • Registers a supply receiver function that will be called as soon as this supply cut off.

    Calling this method is the same as calling this.alsoOff(SupplyReceiver(receiver))

    Parameters

    • receiver: SupplyReceiverFn<TResult>

      Supply receiver function accepting cut off indicator as its only parameter.

    Returns Supply<TResult>

    this instance.

  • Assigns unexpected supply failure handler.

    When a supply cut off due to some failure, and there is no supply receiver registered and still available to handle it, the given handler will be called with failure indicator as its only parameter.

    By default, a warning with unexpected failure reason will be issued to console.

    Parameters

    • Optional handler: ((this, reason) => void)

      A handler to call on unexpected failure, or undefined to reset to default one.

        • (this, reason): void
        • Parameters

          Returns void

    Returns void

Generated using TypeDoc