Skip to content

Instantly share code, notes, and snippets.

@ggrossetie
Last active January 31, 2020 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ggrossetie/ae6ee4b62dbed7461f43471d6040870b to your computer and use it in GitHub Desktop.
Save ggrossetie/ae6ee4b62dbed7461f43471d6040870b to your computer and use it in GitHub Desktop.
class Invoker {
async invoke() {
// we need to add "await" otherwise "convertFromStdin" will not be completed when we "do something"
Invoker.convertFromStdin()
}
static async convertFromStdin() {
console.log('>>> convertFromStdin')
const data = await Invoker.readFromStdin()
console.log('<<< convertFromStdin', data)
}
static async readFromStdin() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('data')
}, 500)
})
}
}
class AsciidoctorRevealJsInvoker extends Invoker {
async invoke() {
console.log('>>> super.invoke()')
await super.invoke()
console.log('<<< super.invoke()')
console.log('do something')
}
}
new AsciidoctorRevealJsInvoker().invoke()
>>> super.invoke()
>>> convertFromStdin
<<< convertFromStdin data
<<< super.invoke()
do something
>>> super.invoke()
>>> convertFromStdin
<<< super.invoke()
do something
<<< convertFromStdin data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment