Created
July 16, 2018 14:32
-
-
Save rook2pawn/afebead5e172d650f4d10fae1ea596de to your computer and use it in GitHub Desktop.
nanocomponent promise ready
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyComponent extends Nanocomponent { | |
constructor(config) { | |
super(); | |
this.ready = new Promise((resolve, reject) => { | |
this._resolve = resolve; | |
}) | |
} | |
createElement(params) { | |
// do stuff | |
} | |
load (el) { | |
this._resolve(); | |
} | |
update () { | |
return true; | |
} | |
} | |
var x = new MyComponent; | |
x.render(); | |
x.ready.then(() => { | |
// hooray | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment