mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-07-11 19:23:10 +00:00
Updated AsyncFunction (markdown)
parent
a855b90acd
commit
47f720899d
|
@ -4,6 +4,7 @@ JScript does not support the `async` keyword. So, WelsonJS uses the `AsyncFuncti
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
|
#### In the webbrowser
|
||||||
```js
|
```js
|
||||||
var STD = require("lib/std");
|
var STD = require("lib/std");
|
||||||
|
|
||||||
|
@ -18,3 +19,23 @@ function main(args) {
|
||||||
|
|
||||||
exports.main = main;
|
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;
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user