I usually just stow the original initialization promise, and return that on future requests...
let _instance = null;
export default async function getResource(opts) {
if (_instance) return instance;
_instance = intializeInstance(otps).then(i => (
_instance = i
));
return _instance;
}
This will stow the promise, returning it initially, then when the concrete instance is there, will start returning that.
I usually just stow the original initialization promise, and return that on future requests... let _instance = null; export default async function getResource(opts) { if (_instance) return instance; _instance = intializeInstance(otps).then(i => ( _instance = i )); return _instance; } This will stow the promise, returning it initially, then when the concrete instance is there, will start returning that.