Skip to content

acetylen/asyncev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsyncEv: asynchronous event objects

AsyncEv leverages asyncio to create events that can be subscribed to and waited for.

Usage

import asyncio
import asyncev
from dataclasses import dataclass

# Create an event
@dataclass
class MyEvent(asyncev.BaseEvent):
    value: str

# Create a handler
async def on_myevent(ev: MyEvent):
    print(f"Got a MyEvent with the value {ev.value}!")

asyncev.bind(MyEvent, on_myevent)

# Emit event (requires a running asyncio event loop)
async def main():
    asyncev.emit(MyEvent(value="hello world"))
    
asyncio.run(main())

Testing

$ python -m unittest

About

Asyncronous named events for python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages