Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bjarneo/pythonevents
Fire events with dictionary attached, and listen to events. Small library.
https://github.com/bjarneo/pythonevents
Last synced: 3 days ago
JSON representation
Fire events with dictionary attached, and listen to events. Small library.
- Host: GitHub
- URL: https://github.com/bjarneo/pythonevents
- Owner: bjarneo
- License: mit
- Created: 2014-06-16T20:10:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-16T20:19:01.000Z (over 10 years ago)
- Last Synced: 2024-04-15T02:09:39.787Z (7 months ago)
- Language: Python
- Size: 141 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PythonEvents
============Fire events with dictionary attached, and listen to events. Small library.
### Example (see cli.py)
```python
import eventse = events.Events()
e.register('Fire', {
'name': 'Bjarne Oeverli',
'nick': 'bjarneo',
'e-mail': '[email protected]',
'options': {
'uno': 'my first',
'dos': 'my second'
}
})# Callback
def test(item):
print item# Listen to event and add callback
e.listen('Fire', test)
# Output:
# {'nick': 'bjarneo', 'options': {'dos': 'my second', 'uno': 'my first'}, 'name': 'Bjarne Oeverli', 'e-mail': '[email protected]'}# Listen to all events
e.listenAll(test)
# Output:
# {'Fire': {'nick': 'bjarneo', 'options': {'dos': 'my second', 'uno': 'my first'}, 'name': 'Bjarne Oeverli', 'e-mail': '[email protected]'}}# Listen to event once, and it gets deleted
e.listenOnce('Fire', test)
# Output:
# {'nick': 'bjarneo', 'options': {'dos': 'my second', 'uno': 'my first'}, 'name': 'Bjarne Oeverli', 'e-mail': '[email protected]'}# Remove event
e.remove('Fire')
```