[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: General purpose notification mechanism for Lua
- From: Matthew Wild <mwild1@...>
- Date: Thu, 31 Dec 2009 00:03:24 +0000
2009/12/30 Tiago Katcipis <tiagokatcipis@gmail.com>:
>
>
> Well I'm experienced with this other systems but i do not master them :-), i
> don't know if i will have a good idea of how to implement it on Lua, that's
> exactly why I'm trying to get some help from you guys.
>
I'm not sure 100% exactly what you're aiming for, but in Prosody we
wrote a small events library. It allows adding handlers to, and
triggering events identified by strings. It also allows you to add a
"priority" to the handlers, to loosely define the order they get
called in. Returning any value other than nil from a handler will halt
the processing of the event and return that value to the code that
fired the event.
The code is at http://hg.prosody.im/trunk/file/tip/util/events.lua
with documentation at http://prosody.im/doc/developers/util/events .
Also take a look at http://lua-users.org/wiki/LuaDesignPatterns for an
alternative (but similar) implementation.
Matthew