Let existing async wtype use helpers.setasyncall
This commit is contained in:
parent
6ba97712f5
commit
92a2138296
|
@ -4,7 +4,6 @@
|
|||
---------------------------------------------------
|
||||
|
||||
-- {{{ Grab environment
|
||||
local setmetatable = setmetatable
|
||||
local pcall = pcall
|
||||
local helpers = require("vicious.helpers")
|
||||
local spawn = require("vicious.spawn")
|
||||
|
@ -51,13 +50,6 @@ function btc_all.async(format, warg, callback)
|
|||
|
||||
spawn.easy_async(cmd, function(stdout) callback(parse(stdout)) end)
|
||||
end
|
||||
|
||||
local function worker(format, warg)
|
||||
local ret
|
||||
btc_all.async(format, warg, function (price) ret = price end)
|
||||
while ret == nil do end
|
||||
return ret
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(btc_all, { __call = function(_, ...) return worker(...) end })
|
||||
return helpers.setasyncall(btc_all)
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
---------------------------------------------------
|
||||
|
||||
-- {{{ Grab environment
|
||||
local setmetatable = setmetatable
|
||||
local spawn = require("vicious.spawn")
|
||||
local helpers = require("vicious.helpers")
|
||||
-- }}}
|
||||
|
||||
|
||||
|
@ -42,16 +42,4 @@ function pkg_all.async(format, warg, callback)
|
|||
end
|
||||
-- }}}
|
||||
|
||||
-- {{{ Packages widget type
|
||||
local function worker(format, warg)
|
||||
local ret = nil
|
||||
|
||||
pkg_all.async(format, warg, function(data) ret = data end)
|
||||
|
||||
while ret==nil do end
|
||||
return ret
|
||||
end
|
||||
-- }}}
|
||||
|
||||
|
||||
return setmetatable(pkg_all, { __call = function(_, ...) return worker(...) end })
|
||||
return helpers.setasyncall(pkg_all)
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local setmetatable = setmetatable
|
||||
local math = { ceil = math.ceil }
|
||||
local string = { match = string.match }
|
||||
|
||||
|
@ -91,13 +90,6 @@ function weather_all.async(format, warg, callback)
|
|||
spawn.easy_async("curl -fs " .. url,
|
||||
function (...) callback(parse(...)) end)
|
||||
end
|
||||
|
||||
local function worker(format, warg)
|
||||
local ret
|
||||
weather_all.async(format, warg, function (weather) ret = weather end)
|
||||
while ret == nil do end
|
||||
return ret
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(weather_all, { __call = function(_, ...) return worker(...) end })
|
||||
return helpers.setasyncall(weather_all)
|
||||
|
|
Loading…
Reference in New Issue