Skip to content

lipan118/EventManager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EventManager

My take on a pythonic, and simple event system. It does not have any dependencies, beyond of course python!

Usage and explanation

####Event: This class represents an event.

Example usage:

e = Event()  # Create event object
e.add_handler(myfunction)  # Register handler
e()  # Fire event, this will call all handlers
e.fire()  # This also same as e()

Other: If a handler raises StopIterator() the event will not execute the rest of the handlers. To bypass checks simply use e.append(myfunction) instead.

####EventManager This class represents a list of events.

Example usage:

em = EventManager()  # Create manager object.
em["myevent"] = Event()  # Add an empty event called "myevent".
em["myevent"].add_handler(myfunction)  # Add handler to an event.
em["myevent"]()  # Fire the event: "myevent".
em.myevent()  # You can also use '.' instead of [""], I prefer using '.'

Other: Every EventManager comes with a global event hook, it fires every time it gets a request to fire an event. It acts like any ol' event, and can be found under EventManager.got_event

Examples

Add examples here, if you use this, please add a link to your code here!

About

My take on a pythonic event manager!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%