refactoring
This commit is contained in:
+4
-4
@@ -58,7 +58,7 @@ end
|
||||
|
||||
function public.event_listener(event, cb)
|
||||
local listener_id = unique_id
|
||||
listeners[listener_id] = {event=event, cb=cb, kill=function(...) temp=arg if arg.n == 0 or arg[1] then kill_listener(listener_id) end end}
|
||||
listeners[listener_id] = {event=event, cb=cb, kill=function(...) auto[arg] = true if arg.n == 0 or arg[1] then kill_listener(listener_id) end end}
|
||||
event_frame:RegisterEvent(event)
|
||||
return listener_id
|
||||
end
|
||||
@@ -67,13 +67,13 @@ function public.on_next_event(event, callback)
|
||||
event_listener(event, function(kill) callback(); kill() end)
|
||||
end
|
||||
|
||||
function public.thread(k, ...) temp=arg
|
||||
function public.thread(k, ...) auto[arg] = true
|
||||
local thread_id = unique_id
|
||||
threads[thread_id] = T('k', L(k, unpack(arg)))
|
||||
return thread_id
|
||||
end
|
||||
|
||||
function public.wait(k, ...) temp=arg
|
||||
function public.wait(k, ...) auto[arg] = true
|
||||
if type(k) == 'number' then
|
||||
when(function() k = k - 1 return k <= 1 end, unpack(arg))
|
||||
else
|
||||
@@ -81,7 +81,7 @@ function public.wait(k, ...) temp=arg
|
||||
end
|
||||
end
|
||||
|
||||
function public.when(c, k, ...) temp=arg
|
||||
function public.when(c, k, ...) auto[arg] = true
|
||||
if c() then
|
||||
return k(unpack(arg))
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user