Software /
code /
verse
Changeset
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 |
parents | 97:ad6006779416 |
children | 99:0f5a8d530fcd |
files | init.lua |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
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);