Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
4362:851885cb332d | 4363:35ebd8e5747a |
---|---|
451 end | 451 end |
452 end | 452 end |
453 return result; | 453 return result; |
454 end | 454 end |
455 | 455 |
456 function api:handle_items(type, added_cb, removed_cb, existing) | |
457 self:hook("item-added/"..type, added_cb); | |
458 self:hook("item-removed/"..type, removed_cb); | |
459 if existing ~= false then | |
460 for _, item in ipairs(self:get_host_items(type)) do | |
461 added_cb({ item = item }); | |
462 end | |
463 end | |
464 end | |
465 | |
456 return _M; | 466 return _M; |