a light-weight event handler
Project description
Teventlet provides a light-weight easy-to-use mechenism for handling events. Each eventlet object is it’s own event, to which you can add callbacks with +=. To call the event, you can call the object with any arguments, or call the invoke method with any arguments.
Usage
tEventlet provides a clean mechenism for handling and managing callbacks
Here is a quick example to get you going.:
>>> from __future__ import print_function >>> from teventlet import teventlet >>> adder = teventlet(lambda x:print(x+1), lambda x:print(x+2)) >>> adder.invoke(2) 3 4 >>> len(adder) 2 >>>
As you can see, we pass two lambdas to the adder: a lambda that prints x+1, and a lambda that prints x+2. You could easily replace these with functions. By calling invoke, we pass in an argument that gets sent to our lambdas. You can also call the event as if it were a function.:
>>> adder(5) 6 7 >>>