Bevy.Events
Bevy.Events is an events system designed to be used with the Bevy dependency injection framework. It uses Gully for creating observable streams of event objects.
Installation
pip install bevy.events
Documentation
Bevy.Events is incredibly straightforward. You can use it as an annotation type on any injectable class.
@bevy.injectable
class Example:
events: bevy.events.EventDispatch
...
It is also possible to have multiple event dispatchers in the same Bevy context by giving them names.
@bevy.injectable
class Example:
events: bevy.events.EventDispatch["my-event-dispatch"]
...
To send an event use the dispatch on the event dispatch and pass it the event name to dispatch and all the args to pass to the watchers.
@bevy.injectable
class Example:
events: bevy.events.EventDispatch
...
async def recieved_message(self, message):
await self.dispatch("message-received", message)
To register a watcher just call watch on the event dispatch and pass it an event name to watch for and a coroutine callback. The callback will be passed all args that were given to the dispatch method.
@bevy.injectable
class Example:
events: bevy.events.EventDispatch
def __init__(self):
self.events.watch("message-received", self.on_message_received)
async def on_message_received(self, message):
...
watch returns a Gully observer so that the event watcher can be enabled or disabled as needed.
The event dispatchers will be shared by all class instances in the Bevy context. Events dispatched on a named dispatcher will only be sent to watchers of that event dispatcher. Any class in the context can access the same same event dispatcher just by giving the annotation the same name.
Release files for bevy.events 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Bevy.events-0.1.4.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Bevy.events-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / Bevy.events-0.1.4.tar.gz
| Download URL | Bevy.events-0.1.4.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a571cc79dcbb43c8434db1bb63fc97672b4aa719ba94dd709604287fe0c4abf
|
|
BLAKE2b-256 checksum How to use checksums |
9f00e1588eee4ed3899216ffd79a114cb36326a89fbd7146d2c486cdb499437e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.0 Darwin/20.5.0
|
Release files / Bevy.events-0.1.4-py3-none-any.whl
| Download URL | Bevy.events-0.1.4-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62c8594dc5a31b9c19516e77b4d2496f4b0388f222665ba542bd68f4ec1d4889
|
|
BLAKE2b-256 checksum How to use checksums |
ca26a38128464e01737b465680a48925b4059bf061f3b35590d1d99be7d3d255
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.0 Darwin/20.5.0
|