Echo JS 0.11.0

<~>

tracker1 1235 days ago. link 1 point
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.