aioemit


Nameaioemit JSON
Version 0.0.1 PyPI version JSON
download
home_page
SummaryA minimalistic async event bus implementation
upload_time2023-05-29 20:11:16
maintainer
docs_urlNone
authoriunary
requires_python
licenseMIT License Copyright (c) 2023 Youssef Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords emitter event bus pubsub async subscribe emit publish aioemit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![aioemit](https://github.com/iunary/aioemit/actions/workflows/app.yml/badge.svg)](https://github.com/iunary/aioemit/actions/workflows/app.yml)

# aioemit

aioemit allows you to manage events asynchonosly and notify subscribers when those events occur. It provides a simple way to implement event bus pattern in an event driven architecture application.

## Installation

```bash
pip install aioemit
```

## Usage

### Creating Events

The `Event` class represents an event with a specified event type and optional data. You can create an event by initializing an instance of the `Event` class with the event type and data (if any).

```python
event = Event("example_event", "example_data")
```

### Creating an Emitter

To use the event emitter, create an instance of the `Emitter` class.

```python
emitter = Emitter()
```

### Subscribing to Events

To subscribe to events, use the `subscribe` method of the `Emitter` class. Pass the event type and an observer function that will be called when the event is emitted.

```python
def event_observer(event):
    # Handle the event
    print("Received event:", event)

emitter.subscribe("example_event", event_observer)
```

### Unsubscribing from Events

If you no longer want to receive notifications for a specific event, you can unsubscribe from it using the `unsubscribe` method. Provide the event type and the observer function that you want to remove.

```python
emitter.unsubscribe("example_event", event_observer)
```

### Emitting Events

To emit an event and notify all subscribers, use the `emit` method of the `Emitter` class. Pass the event you want to emit.

```python
event = Event("example_event", "example_data")
await emitter.emit(event)
```

The `emit` method will asynchronously call all the subscribed observer functions that are associated with the event type.


## License

This project is licensed under the [MIT License](LICENSE). Feel free to use, modify, and distribute the code as per the terms of the license.



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aioemit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "emitter,event bus,pubsub,async,subscribe,emit,publish,aioemit",
    "author": "iunary",
    "author_email": "contact@yusuf.im",
    "download_url": "https://files.pythonhosted.org/packages/df/a5/23a4d79c0160983ec3a55e9c7dca38922fe8b94236b0053b367465a940d3/aioemit-0.0.1.tar.gz",
    "platform": null,
    "description": "[![aioemit](https://github.com/iunary/aioemit/actions/workflows/app.yml/badge.svg)](https://github.com/iunary/aioemit/actions/workflows/app.yml)\n\n# aioemit\n\naioemit allows you to manage events asynchonosly and notify subscribers when those events occur. It provides a simple way to implement event bus pattern in an event driven architecture application.\n\n## Installation\n\n```bash\npip install aioemit\n```\n\n## Usage\n\n### Creating Events\n\nThe `Event` class represents an event with a specified event type and optional data. You can create an event by initializing an instance of the `Event` class with the event type and data (if any).\n\n```python\nevent = Event(\"example_event\", \"example_data\")\n```\n\n### Creating an Emitter\n\nTo use the event emitter, create an instance of the `Emitter` class.\n\n```python\nemitter = Emitter()\n```\n\n### Subscribing to Events\n\nTo subscribe to events, use the `subscribe` method of the `Emitter` class. Pass the event type and an observer function that will be called when the event is emitted.\n\n```python\ndef event_observer(event):\n    # Handle the event\n    print(\"Received event:\", event)\n\nemitter.subscribe(\"example_event\", event_observer)\n```\n\n### Unsubscribing from Events\n\nIf you no longer want to receive notifications for a specific event, you can unsubscribe from it using the `unsubscribe` method. Provide the event type and the observer function that you want to remove.\n\n```python\nemitter.unsubscribe(\"example_event\", event_observer)\n```\n\n### Emitting Events\n\nTo emit an event and notify all subscribers, use the `emit` method of the `Emitter` class. Pass the event you want to emit.\n\n```python\nevent = Event(\"example_event\", \"example_data\")\nawait emitter.emit(event)\n```\n\nThe `emit` method will asynchronously call all the subscribed observer functions that are associated with the event type.\n\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE). Feel free to use, modify, and distribute the code as per the terms of the license.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Youssef  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A minimalistic async event bus implementation",
    "version": "0.0.1",
    "project_urls": null,
    "split_keywords": [
        "emitter",
        "event bus",
        "pubsub",
        "async",
        "subscribe",
        "emit",
        "publish",
        "aioemit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b304aee731bc915b705b4535d9e8b0b6f9b9cdab351b524a3fd419931768deb",
                "md5": "c46bf8cae902822e70358003c30f52f2",
                "sha256": "8aa6cab24a1ce018e75729c3de23aceac14c167bee4d7ec0d73c85c7d42d7efc"
            },
            "downloads": -1,
            "filename": "aioemit-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c46bf8cae902822e70358003c30f52f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4980,
            "upload_time": "2023-05-29T20:11:14",
            "upload_time_iso_8601": "2023-05-29T20:11:14.365802Z",
            "url": "https://files.pythonhosted.org/packages/2b/30/4aee731bc915b705b4535d9e8b0b6f9b9cdab351b524a3fd419931768deb/aioemit-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dfa523a4d79c0160983ec3a55e9c7dca38922fe8b94236b0053b367465a940d3",
                "md5": "2a6fac0fa2b5ab8213073f9888b8281c",
                "sha256": "811be2be0647d46afe64becc1c7ce09da782eea45ebe5dc379c93b35f3897d40"
            },
            "downloads": -1,
            "filename": "aioemit-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2a6fac0fa2b5ab8213073f9888b8281c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4016,
            "upload_time": "2023-05-29T20:11:16",
            "upload_time_iso_8601": "2023-05-29T20:11:16.330670Z",
            "url": "https://files.pythonhosted.org/packages/df/a5/23a4d79c0160983ec3a55e9c7dca38922fe8b94236b0053b367465a940d3/aioemit-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-29 20:11:16",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "aioemit"
}
        
Elapsed time: 0.07478s