Metadata-Version: 2.1
Name: event_emitter_asyncio
Version: 1.0.0
Summary: Super simple event emitter in Python 3, built with asyncio. No decorators required.
Author-email: Joel Tok <jttctc@gmail.com>
Project-URL: Homepage, https://github.com/joeltok/py-event-bus
Project-URL: Bug Tracker, https://github.com/joeltok/py-event-bus/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# py-event-bus

Super simple event bus in Python 3, built with asyncio. No decorators required. Built around a subset of the NodeJS [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) API. 

A full write up and explanation can be found [here](https://joeltok.com/blog/2021-3/building-an-event-bus-in-python).

## Usage

```python
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:
```sh
> cats
> dogs
```

## Development Setup

```sh
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 

```sh
python3 -m pytest src/py-event-bus/
```

## Packaging

Setup

```sh
source venv/bin/activate
python3 -m pip install --upgrade build
python3 -m pip install --upgrade twine
```

Package:

```sh
python3 -m build
twine upload dist/*
```
