This seems useful at first. But you can really easily achieve the same effect with just a single promise:
const myAsyncObject = (async () => {
// some code...
})();
// and then use this whenever you need it.
const theObject = await myAsyncObject;
Or if you only want to run it the moment you need it:
let promise = null;
function getAsyncObject() {
if (promise) return promise;
promise = (async () => {
// some code...
})();
return promise;
}
We should get rid of once since it would remove a lot of unnecessary complexity.
This seems useful at first. But you can really easily achieve the same effect with just a single promise:
Or if you only want to run it the moment you need it:
We should get rid of
oncesince it would remove a lot of unnecessary complexity.