Skip to main content

An implementation of events and asynchronous callbacks using decorators.

Project description


Asyevent

An implementation of events and asynchronous callbacks using decorators.

Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

An implementation of events and asynchronous callbacks using decorators. The project is currently in development. The main features are stables and work perfectly as I've tested, but if you notice any issue, or you have a suggestion to make, it's greatly appreciated.

Built using

GETTING STARTED

Installation

pip install asyevent

Usage

import asyncio

# imports needed classes
from asyevent import EventManager

# creates a main event manager
manager = EventManager()

# creates an event
sample_event = manager.create_event('sample_event')


# adds `call_on_event` coroutine as sample_event's callback
@sample_event.as_callback()
async def sample_event_callback(text: str):
    print(text)
    await asyncio.sleep(2)


# uses `.after` event which refers to an event that is raised
# when the parent event's callbacks are ended (data_lost)
@sample_event.after.as_callback()
async def after_event(time_took: int, *args):
    # invokes the command `say`
    await manager.invoke_command('say', f'I\'ve been here for {time_took} seconds')


# adds the `hello` coroutine as a callback of the command `say_hello`
@manager.as_command(name='say')
async def say_stm(name: str):
    print(f'Hello, {name} !')


if __name__ == '__main__':
    # raises the event `sample_event`
    manager.loop.run_until_complete(
        sample_event('Hello, world !')
    )

More example in asyevent/examples/ folder.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Zucchinetti Hervé

GitHub

Readme template

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

asyevent-0.1.3.tar.gz (11.5 kB view hashes)

Uploaded Source

Built Distribution

asyevent-0.1.3-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page