Last active
January 31, 2020 11:22
-
-
Save ggrossetie/ae6ee4b62dbed7461f43471d6040870b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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() |
This file contains hidden or 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
>>> super.invoke() | |
>>> convertFromStdin | |
<<< convertFromStdin data | |
<<< super.invoke() | |
do something |
This file contains hidden or 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
>>> 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