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.
async function logToConsole() {
let data = await getSubscriptionData(
sendHTTPRequest('http://website.com') // returns an observable
);
console.log(data);
}
async function getFirstLottoNumber() {
return await getSubscriptionData(lottoNumbersObservable);
}
npm i @writetome51/get-subscription-data
import {getSubscriptionData} from '@writetome51/get-subscription-data';