Software /
code /
prosody
Diff
core/modulemanager.lua @ 4363:35ebd8e5747a
modulemanager: Add module:handle_items() to allow a module to more easily handle a list of items on a host
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 29 Aug 2011 13:09:29 -0400 |
parent | 4344:a24ee48ec30d |
child | 4381:bf81b4784853 |
line wrap: on
line diff
--- a/core/modulemanager.lua Mon Aug 29 13:00:33 2011 -0400 +++ b/core/modulemanager.lua Mon Aug 29 13:09:29 2011 -0400 @@ -453,4 +453,14 @@ return result; end +function api:handle_items(type, added_cb, removed_cb, existing) + self:hook("item-added/"..type, added_cb); + self:hook("item-removed/"..type, removed_cb); + if existing ~= false then + for _, item in ipairs(self:get_host_items(type)) do + added_cb({ item = item }); + end + end +end + return _M;