Contracts-TS Documentation
    Preparing search index...

    Interface Contracts

    The actual implementation used for Contracts itself. It is used to bootstrap Contracts without it knowing the implementation if Contracts. It does know how to load the default from contracts-impl. However, the design is open to have it replaced with an alternative implementation.

    interface Contracts {
        bind<T>(
            contract: Contract<T>,
            promisor: PromisorType<T>,
            bindStrategy?: BindStrategyType,
        ): AutoClose;
        claim<T>(contract: Contract<T>): OptionalType<T>;
        enforce<T>(contract: Contract<T>): RequiredType<T>;
        isBound<T>(contract: Contract<T>): boolean;
        open(): AutoClose;
    }

    Hierarchy

    • Open
      • Contracts
    Index

    Methods

    • Establish a binding between a Contract and a Promisor

      Type Parameters

      • T

        The type of the value returned by the promisor

      Parameters

      • contract: Contract<T>

        the contract to bind the Promisor

      • promisor: PromisorType<T>

        the Promisor for the given contract

      • OptionalbindStrategy: BindStrategyType

        the binding strategy

      Returns AutoClose

      Use to release (unbind) this contract

      ContractException when contract is already bound, can't be replaced or not accepting bindings

      SecurityException when permission to bind is denied

      IllegalArgumentException may throw when an argument is null

    • Claim the deliverable from a bound contract.

      Type Parameters

      • T

        type of value returned

      Parameters

      Returns OptionalType<T>

      the value returned by the bound Promisor. A Promisor can return null

      ContractException if Promisor binding does not exist for the contract

      SecurityException if permission is denied

      IllegalArgumentException may throw when an argument is null

    • Enforce the deliverable from a bound contract.

      Type Parameters

      • T

        type of value returned

      Parameters

      Returns RequiredType<T>

      the value returned by the bound Promisor, but never null or undefined

      ContractException if Promisor binding does not exist for the contract, or the deliverable is null

      SecurityException if permission is denied

      IllegalArgumentException may throw when an argument is null

    • Checks if the contract is bound to a Promisor

      Type Parameters

      • T

        The type of the value returned by the promisor

      Parameters

      Returns boolean

      true iif bound

      IllegalArgumentException may throw when an argument is null