Super simple event emitter in Python 3, built with asyncio. No decorators required.
Project description
event-emitter-asyncio
Super simple event emitter in Python 3, built with asyncio. No decorators required. Built around a subset of the NodeJS EventEmitter API.
A full write up and explanation for how this module works can be found here.
Usage
from event_emitter_asyncio.EventEmitter import EventEmitter
event_emitter = EventEmitter()
async def func(event):
for pet in event['pets']:
print(pet)
event_data = {
'pets': ['cats', 'dogs']
}
event_emitter.add_listener('some-event', func)
event_emitter.emit('some-event', event_data)
event_emitter.remove_listener('some-event', func)
This will give:
> cats
> dogs
Using this repo
Development
git clone git@github.com:joeltok/py-event-bus.git
cd ./py-event-bus
python3 -m venv ./venv
source venv/bin/activate
pip3 install pytest
pip3 install pytest-asyncio
Testing
python3 -m pytest src/py-event-bus/
Packaging
source venv/bin/activate
python3 -m pip install --upgrade build
python3 -m pip install --upgrade twine
python3 -m build
twine upload dist/*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for event_emitter_asyncio-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5522d221411ef8082ca63023007c793123ed0b1733ce33a66cbf2535c02a551c |
|
MD5 | 531fdbe99eb4065592077dfd7ef2d3a0 |
|
BLAKE2b-256 | 60188b029171beb759a9d5e4d9cdd8682801211c8b302bdd2669ae1ace4a48dd |
Close
Hashes for event_emitter_asyncio-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce9d7e420f1c9da0c3ebebcb6d15eeeeceb24207f4c41d8f0205f6edb2cd9e0e |
|
MD5 | 1d4081532276c84cf2291a13fa3046ad |
|
BLAKE2b-256 | aa85f623c26f0d8617f77f94a2b41247a4c0d8ea7336ed0bd0f0399f681c7fd8 |