-- 引入Async
local Async = require("Async")
-- 创建Async
-- 可传递参数到接下来的调用中
Async.New(...)
-- 注册异步调用
Async.New(...)
:Ok(function(ok, no, ...) return no() end) -- 在Ok管道注册回调, 之后进入No管道
:No(function(ok, no, ...) return ok() end) -- 在No管道注册回调, 之后进入Ok管道
:Ok(function(ok, no, ...) return no() end) -- 在Ok管道注册回调, 之后进入No管道
:No(function(ok, no, ...) return ok() end) -- 在No管道注册回调, 之后进入Ok管道
-- 异常捕获
Async.New(...)
:Error(function() print("捕获异常...") end) -- 注册异常捕获函数
:Ok(function(ok, no, ...) return no() end) -- 在Ok管道注册回调, 之后进入No管道
:No(function(ok, no, ...) return ok() end) -- 在No管道注册回调, 之后进入Ok管道
:Ok(function(ok, no, ...) return no() end) -- 在Ok管道注册回调, 之后进入No管道
:No(function(ok, no, ...) return ok() end) -- 在No管道注册回调, 之后进入Ok管道
lua 异步调用 Async库
最新推荐文章于 2024-08-03 23:25:03 发布