• Helps to build a promise associated to a subscription callback through which updates can be pushed to the promise. This promise is resolved with the value of the latest update when a resolution criterion is met. It is rejected with a custom error/reason if a rejection criterion is met or on timeout (optional). Rejection takes precedent.

    Returns

    An object containing both a subscription callback and a promise which resolves or rejects depending on the values pushed to the callback.

    Type Parameters

    • SubscriptionType

    Parameters

    Returns {
        promise: Promise<SubscriptionType>;
        subscription: ((value: SubscriptionType) => void);
    }

    • promise: Promise<SubscriptionType>
    • subscription: ((value: SubscriptionType) => void)
        • (value: SubscriptionType): void
        • Parameters

          • value: SubscriptionType

          Returns void