Super simple event emitter in Python 3, built with asyncio. No decorators required.
Project description
py-event-bus
Super simple event bus in Python 3, built with asyncio. No decorators required. Built around a subset of the NodeJS EventEmitter API.
A full write up and explanation can be found here.
Usage
from py_event_bus.EventBus import EventBus
event_bus = EventBus()
async def func(event):
for pet in event['pets']:
print(pet)
event_data = {
'pets': ['cats', 'dogs']
}
event_bus.add_listener('some-event', func)
event_bus.emit('some-event', event_data)
event_bus.remove_listener('some-event', func)
This will give:
> cats
> dogs
Development Setup
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
Setup
source venv/bin/activate
python3 -m pip install --upgrade build
python3 -m pip install --upgrade twine
Package:
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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0690cfaba8ea178c3d1e67f8aa70adbf6bd23d36b29eacba2da90fd0ee0c3c7 |
|
MD5 | fd5bd943af112f65ab3bfd5d265dce12 |
|
BLAKE2b-256 | b9b63da82ce100f8e76539f4a972aef942007bcafbbc2245030f9d8bf0d8654f |
Close
Hashes for event_emitter_asyncio-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4c2dad832dff8e311078e0cb06d7fdb06cdb888a2eeede1d5ca24b6a1cdd2a3 |
|
MD5 | 1a23a3dc9915ec8d0e58baff4875516a |
|
BLAKE2b-256 | 9549f91ed4651181006a648037bb99d3762afe4b39dd9263f3b8ec66ed362460 |