Software /
code /
prosody
Changeset
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 |
parents | 4362:851885cb332d |
children | 4364:af40cf682eba |
files | core/modulemanager.lua |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
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;