jcevents Library Documentation =============================
Introduction
The jcevents library is a lightweight event-driven framework for
Python that allows you to implement event handling and listeners in your
applications. This documentation provides a guide on how to use the
library effectively.
Installation
You can install the jcevents library using pip:
pip install jcevents
Getting Started
To begin using the jcevents library, follow these steps:
- Import the necessary modules:
import jcevents
from jcevents import Event, Listener, register_listeners, fire_all_postponed
- Define your custom events by inheriting from the
Eventclass and implementing the required logic:
class MyEvent(Event):
def __init__(self, success: bool):
super(MyEvent, self).__init__()
self.success = success
- Implement event listeners by inheriting from the
Listenerclass and overriding thehandlemethod:
class MyListener(Listener):
def handle(self, event: MyEvent):
if event.success:
print("> Event success !!!")
else:
print("> Event not success")
- Register your event listeners with their corresponding events using
the
register_listenersfunction:
register_listeners({
MyEvent: MyListener
})
- Create instances of your events, postpone them if needed, and then
fire all postponed events using
fire_all_postponed:
my_event = MyEvent(success=True)
my_event.postpone()
fire_all_postponed()
Example Usage
Here's an example demonstrating how to use the jcevents library in a
Python script:
import jcevents
from jcevents import Event, Listener, register_listeners, fire_all_postponed
class MyEvent(Event):
def __init__(self, success: bool):
super(MyEvent, self).__init__()
self.success = success
class MyListener(Listener):
def handle(self, event: MyEvent):
if event.success:
print("> Event success !!!")
else:
print("> Event not success")
def main():
register_listeners({
MyEvent: MyListener
})
my_event = MyEvent(success=True)
my_event.postpone()
fire_all_postponed()
if __name__ == "__main__":
main()
Conclusion
The jcevents library provides a simple yet powerful way to implement
event-driven architecture in your Python applications. By defining
custom events, implementing event listeners, and using the provided
functions, you can easily manage and handle events in your projects.
Metadata
Release files for jcevents 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jcevents-1.0.1.tar.gz | 2.7 kB | Without provenance | Details for jcevents-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jcevents-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for jcevents-1.0.1-py3-none-any.whl |
Total release size: 6.1 kB
Release files / jcevents-1.0.1.tar.gz
| Download URL | jcevents-1.0.1.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1533a75fa1f5be474e28bb75134f575c2e4ac75c1b2f02e6995258e816bd72c
|
|
BLAKE2b-256 checksum How to use checksums |
1fef27d9aeeb9424a587355d3548f3fd6e7a77758c3f1f6da5b6b22817b8f0e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Release files / jcevents-1.0.1-py3-none-any.whl
| Download URL | jcevents-1.0.1-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f83664da59e94a0e55c1760def5a3ed8602383e3206ec6b0af1261613f278d77
|
|
BLAKE2b-256 checksum How to use checksums |
63b159481ea2e327e605ab613217272fe2e420df85932fccb588946e6806cbcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Security for jcevents 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.