event-channel-0.4.3
توضیحات
Pub sub implementation
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | event-channel-0.4.3 |
| نام | event-channel |
| نسخه کتابخانه | 0.4.3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | mandrewcito |
| ایمیل نویسنده | anbaalo@gmail.com |
| آدرس صفحه اصلی | https://github.com/mandrewcito/event_channel |
| آدرس اینترنتی | https://pypi.org/project/event-channel/ |
| مجوز | - |
# Event Channel
[](https://www.paypal.me/mandrewcito/1)

[](https://pepy.tech/project/event-channel)
[](https://pepy.tech/project/event-channel/month)




Another library with a pub/sub implementation. You can subscribe functions to a certain topic (aka event). When a message is sent through this event callback functions subscribed will be executed.
```python
from event_channel import EventChannel
mychannel = EventChannel() # You can also import channel, is an instance already created
def callback(x):
x = x + 1
print(x)
mychannel.subscribe("myevent", callback)
mychannel.publish("myevent", 345)
channel.unsubscribe("myevent", callback)
```
```python
from event_channel.threaded_event_channel import ThreadedEventChannel
mychannel = ThreadedEventChannel(blocking=False) # You can also import non_blocking_channel, is an instance already created
def callback(x):
x = x + 1
print(x)
mychannel.subscribe("myevent", callback)
mychannel.subscribe("myevent", callback2)
threads = mychannel.publish("myevent", 345)
# Wait thread finish
for thread in threads:
thread.join()
```
```python
from event_channel.threaded_event_channel import ThreadedEventChannel
my_blocking_channel = ThreadedEventChannel() # You can also import channel, is an instance already created
def callback(x):
x = x + 1
print(x)
mychannel.subscribe("myevent", callback)
mychannel.subscribe("myevent", callback2)
threads = mychannel.publish("myevent", 345)
#at this point all threads are finished
```
نحوه نصب
نصب پکیج whl event-channel-0.4.3:
pip install event-channel-0.4.3.whl
نصب پکیج tar.gz event-channel-0.4.3:
pip install event-channel-0.4.3.tar.gz