Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 942 Bytes

README.md

File metadata and controls

28 lines (23 loc) · 942 Bytes

getSubscriptionData(
      subscribable: Subscribable<any>
): Promise<any>

Async function that only returns the first data result of a Subscription (to a Subscribable)
and then unsubscribes automatically. Useful if you only want the first result and don't
need to keep the Subscription open.

Examples

async function logToConsole() {
    let data = await getSubscriptionData(
        sendHTTPRequest('http://website.com') // returns an observable
    );
    console.log(data);
}

async function getFirstLottoNumber() {
    return await getSubscriptionData(lottoNumbersObservable);
}

Installation

npm i @writetome51/get-subscription-data

Loading

import {getSubscriptionData} from '@writetome51/get-subscription-data';