Let existing async wtype use helpers.setasyncall

This commit is contained in:
Nguyễn Gia Phong 2019-05-15 16:05:16 +07:00
parent 6ba97712f5
commit 92a2138296
3 changed files with 4 additions and 32 deletions

View File

@ -4,7 +4,6 @@
--------------------------------------------------- ---------------------------------------------------
-- {{{ Grab environment -- {{{ Grab environment
local setmetatable = setmetatable
local pcall = pcall local pcall = pcall
local helpers = require("vicious.helpers") local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn") 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) spawn.easy_async(cmd, function(stdout) callback(parse(stdout)) end)
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)

View File

@ -4,8 +4,8 @@
--------------------------------------------------- ---------------------------------------------------
-- {{{ Grab environment -- {{{ Grab environment
local setmetatable = setmetatable
local spawn = require("vicious.spawn") local spawn = require("vicious.spawn")
local helpers = require("vicious.helpers")
-- }}} -- }}}
@ -42,16 +42,4 @@ function pkg_all.async(format, warg, callback)
end end
-- }}} -- }}}
-- {{{ Packages widget type return helpers.setasyncall(pkg_all)
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 })

View File

@ -5,7 +5,6 @@
-- {{{ Grab environment -- {{{ Grab environment
local tonumber = tonumber local tonumber = tonumber
local setmetatable = setmetatable
local math = { ceil = math.ceil } local math = { ceil = math.ceil }
local string = { match = string.match } local string = { match = string.match }
@ -91,13 +90,6 @@ function weather_all.async(format, warg, callback)
spawn.easy_async("curl -fs " .. url, spawn.easy_async("curl -fs " .. url,
function (...) callback(parse(...)) end) function (...) callback(parse(...)) end)
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)