2.0.0 • Published 4 years ago

@writetome51/get-subscription-data v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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';