Contracts-TS Documentation
    Preparing search index...

    Interface PromisorFactory

    Helper methods for creating and chaining Promisors used for Contracts.bind().

    interface PromisorFactory {
        createExtractor<T, R>(
            promisor: PromisorType<T>,
            extractor: TransformType<T, R>,
        ): Promisor<R>;
        createLifeCycle<T>(promisor: PromisorType<T>): Promisor<T>;
        createSingleton<T>(promisor: PromisorType<T>): Promisor<T>;
        createValue<T>(deliverable: OptionalType<T>): Promisor<T>;
    }
    Index

    Methods

    • Extract values from the deliverable of a source Promisor. Note: increment and decrementUsage are relayed to the source promisor.

      Type Parameters

      • T

        the type of deliverable

      • R

        the new Promisor deliverable type

      Parameters

      • promisor: PromisorType<T>

        the source promisor

      • extractor: TransformType<T, R>

        the function that gets an object from the deliverable. For example Person => Age

      Returns Promisor<R>

      the new Promisor

    • Reference counted, lazy loaded, with opt-in 'open' and 'close' invoked on deliverable. Note: increment and decrementUsage are relayed to the source promisor.

      Type Parameters

      • T

        the type of deliverable

      Parameters

      • promisor: PromisorType<T>

        the source promisor

      Returns Promisor<T>

      the new Promisor

    • Creates a Promisor that only calls the source Promisor once and then always returns that value. Note: increment and decrementUsage are relayed to the source promisor.

      Type Parameters

      • T

        the type of deliverable

      Parameters

      • promisor: PromisorType<T>

        the source Promisor

      Returns Promisor<T>

      The new Promisor