-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.lua
45 lines (40 loc) · 841 Bytes
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local async = require('async')
---- async call ----
function step1(a, b, c, next)
print('step1', a, b, c)
-- you may call the in some callback
async.next(next)
end
local function step2(a, b, c, next)
print('step2', a, b, c)
async.next(next)
end
local function step3(a, b, c, next)
print('step3', a, b, c)
async.next(next)
end
async.call(
{step1, 1, 2, 3},
{step2, 4, 5, 6},
{step3, 7, 8, 9})
---- water fall ----
async.waterfall({
function (callback)
callback(nil, 1, 2)
end,
function (callback, a, b)
print(a, b)
callback(nil, 3)
end,
function(callback, a)
print(a)
callback(nil, 4)
end
},
function (err, result)
if err then
print('error:', err)
else
print(result)
end
end)