diff --git a/AsyncFunction.md b/AsyncFunction.md index 293eaaa..04ecc7b 100644 --- a/AsyncFunction.md +++ b/AsyncFunction.md @@ -4,6 +4,7 @@ JScript does not support the `async` keyword. So, WelsonJS uses the `AsyncFuncti ### Examples +#### In the webbrowser ```js var STD = require("lib/std"); @@ -18,3 +19,23 @@ function main(args) { exports.main = main; ``` + +#### In the console + +``` +function main(args) { + [5, 4, 3, 2, 1].forEach(function(x) { + new AsyncFunction('sub_01', 'mymodule').run(x); + }); +} + +function _async_sub_01(args) { + var x = args[0]; + + sleep(x * 1000); + console.log(x); +} + +exports.main = main; +exports._async_sub_01 = _async_sub_01; +``` \ No newline at end of file