Skip to content

Instantly share code, notes, and snippets.

@ecwyne
Last active April 20, 2017 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecwyne/9b49a42cbdf835c9c8b9d7f3f6fa0526 to your computer and use it in GitHub Desktop.
Save ecwyne/9b49a42cbdf835c9c8b9d7f3f6fa0526 to your computer and use it in GitHub Desktop.
Documentation for hydra.ready()

ready

Returns promise that resolves when initialization is complete.

/**
* @name ready
* @summary returns promise that resolves when initialization is complete
* @return {object} promise - resolving if init success or rejecting otherwise
*/
ready()

If you are using hydra in the same file it's being initialized in, then you can wait directly on the promise returned by hydra.init() before proceding with other hydra methods.

// index.js
hydra.init({...})
  .then(...);

However, if you are importing your hydra instance from a separate file, you will need to call the hydra.ready() method. hydra.ready() returns the exact same promise that hydra.init() does, though it does so without re-initializing the hydra instance.

// my-hydra.js
import hydra from 'hydra';

hydra.init({...});
export default hydra;
// service.js
import hydra from './my-hydra.js';

hydra.ready().then(...);

You can use hydra.ready() any time after you have called hydra.init() to wait for initialization to complete.

@jkyberneees
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment