Software /
code /
verse
Diff
init.lua @ 98:1dccff7df2d5
verse: Add verse.eventable() to give a passed object :event() and :hook()/:unhook() methods and return it again
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 21 Aug 2010 14:38:16 +0100 |
parent | 96:f0aec10023aa |
child | 124:3659ba3b8dfa |
line wrap: on
line diff
--- a/init.lua Sat Aug 21 14:37:10 2010 +0100 +++ b/init.lua Sat Aug 21 14:38:16 2010 +0100 @@ -126,6 +126,16 @@ return self.events.remove_handler(name, handler); end +function verse.eventable(object) + object.events = events.new(); + object.hook, object.unhook = stream.hook, stream.unhook; + local fire_event = object.events.fire_event; + function object:event(name, ...) + return fire_event(name, ...); + end + return object; +end + function stream:add_plugin(name) if require("verse.plugins."..name) then local ok, err = verse.plugins[name](self);