Guest User

Untitled

a guest
Jan 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. return function()
  2. local methods = {}
  3. local meta = {
  4. __add = function(delegates, func)
  5. methods[#methods + 1] = func
  6. return delegates
  7. end,
  8. __sub = function(delegates, func)
  9. for i, f in ipairs(methods) do
  10. if f == func then
  11. table.remove(methods, i)
  12. end
  13. end
  14. return delegates
  15. end,
  16. __call = function(delegates, ...)
  17. for _, f in ipairs(methods) do
  18. f(...)
  19. end
  20. end
  21. }
  22. return setmetatable({}, meta)
  23. end
Add Comment
Please, Sign In to add comment