All Projects → pyeve → Events

pyeve / Events

Licence: other
Python Event Handling the C# Style

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Events

preact-delegate
Preact delegate DOM events
Stars: ✭ 17 (-93.46%)
Mutual labels:  events
IwEngine
This is an engine that I initially started building after taking a game coding class in high school. I didn't like Unity so tried to make something more code focused that was personally easier to use.
Stars: ✭ 97 (-62.69%)
Mutual labels:  events
sugarcalendar-core
Sugar Calendar plugin for WordPress
Stars: ✭ 40 (-84.62%)
Mutual labels:  events
contao-events subscriptions
Contao extension that allows members of your website to subscribe to the events
Stars: ✭ 12 (-95.38%)
Mutual labels:  events
js-training
JS Training Course
Stars: ✭ 39 (-85%)
Mutual labels:  events
Smart-Inspector
Fluent re-take on Unity Inspector UX. Packed with QoL improvements.
Stars: ✭ 680 (+161.54%)
Mutual labels:  events
attribute-events
🔥 Fire events on attribute changes of your Eloquent model
Stars: ✭ 198 (-23.85%)
Mutual labels:  events
Circuits
circuits is a Lightweight Event driven and Asynchronous Application Framework for the Python Programming Language with a strong Component Architecture.
Stars: ✭ 256 (-1.54%)
Mutual labels:  events
watermill-http
HTTP Pub/Sub for the Watermill project.
Stars: ✭ 16 (-93.85%)
Mutual labels:  events
input-event
🎹 Read and parse input device(like mouse, keyboard, joystick and IR-Remote)'s event data.
Stars: ✭ 45 (-82.69%)
Mutual labels:  events
yii2-forms
Forms CRUD - formbuilder, generator code
Stars: ✭ 32 (-87.69%)
Mutual labels:  events
react-scroll-activator
A React Component that watches for a scroll event and triggers behavior
Stars: ✭ 19 (-92.69%)
Mutual labels:  events
horizon-exporter
Export Laravel Horizon metrics using this Prometheus exporter.
Stars: ✭ 17 (-93.46%)
Mutual labels:  events
OpenSleigh
OpenSleigh is a Saga management library for .NET Core.
Stars: ✭ 198 (-23.85%)
Mutual labels:  events
http-event-stream
📡 Modern spec-compliant Server Sent Events stream implementation.
Stars: ✭ 16 (-93.85%)
Mutual labels:  events
events
Tiny type-safe event emitter
Stars: ✭ 25 (-90.38%)
Mutual labels:  events
LowLevelInput.Net
A thread safe and event driven LowLevelMouse and LowLevelKeyboard Hook
Stars: ✭ 32 (-87.69%)
Mutual labels:  events
Tx
Tx (LINQ to Events)
Stars: ✭ 261 (+0.38%)
Mutual labels:  events
react-keyboard-shortcuts
A declarative library for handling hotkeys based on explicit priority in React applications
Stars: ✭ 23 (-91.15%)
Mutual labels:  events
OpenCQRS
.NET Standard framework to create simple and clean design. Advanced features for DDD, CQRS and Event Sourcing.
Stars: ✭ 546 (+110%)
Mutual labels:  events

Events

The C# language provides a handy way to declare, subscribe to and fire events. Technically, an event is a "slot" where callback functions (event handlers) can be attached to - a process referred to as subscribing to an event. Here is a handy package that encapsulates the core to event subscription and event firing and feels like a "natural" part of the language.

::

>>> def something_changed(reason): 
...     print "something changed because %s" % reason 

>>> from events import Events
>>> events = Events()
>>> events.on_change += something_changed

Multiple callback functions can subscribe to the same event. When the event is fired, all attached event handlers are invoked in sequence. To fire the event, perform a call on the slot:

::

>>> events.on_change('it had to happen')
'something changed because it had to happen'

By default, Events does not check if an event can be subscribed to and fired. You can predefine events by subclassing Events and listing them. Attempts to subscribe to or fire an undefined event will raise an EventsException.

::

>>> class MyEvents(Events):
...     __events__ = ('on_this', 'on_that', )

>>> events = MyEvents()

# this will raise an EventsException as `on_change` is unknown to MyEvents:
>>> events.on_change += something_changed

You can also predefine events for a single Events instance by passing an iterator to the constructor.

::

>>> events = Events(('on_this', 'on_that'))

# this will raise an EventsException as `on_change` is unknown to events:
>>> events.on_change += something_changed

Unsubscribing

There may come a time when you no longer want to be notified of an event. In this case, you unsubscribe in the natural counterpart to += by using -=.

::

# We no longer want to be notified, take us out of the event callback list
>>> events.on_change -= something_changed

You may also want to unsubscribe for memory management reasons. The Events() instance will hold a reference something_changed. If this is a member method of an object, and the lifetime of the Events() instance is greater than that object, it will keep it around longer than would be the normal case.

Documentation

Complete documentation is available at http://events.readthedocs.org

Installing

Events is on PyPI so all you need to do is:

::

pip install events

Testing

Just run:

::

python setup.py test

Or use tox to test the package under all supported Pythons: 2.7, 3.4+

Licenseing

Events is BSD licensed. See the LICENSE_ for details.

Contributing

Please see the Contribution Guidelines_.

Attribution

Based on the excellent recipe by Zoran Isailovski_, Copyright (c) 2005.

.. _Contribution Guidelines: https://github.com/pyeve/events/blob/master/CONTRIBUTING.rst .. _LICENSE: https://github.com/pyeve/events/blob/master/LICENSE .. _Zoran Isailovski: http://code.activestate.com/recipes/410686/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].