Using in Multiple Scripts
drixie opened this issue · 1 comments
drixie commented
How do I use this event emitter in multiple scripts?
In NodeJS, I can export the event in one script, and subscribe to a channel in another script after importing the same channel.
How do I so the same with Pyee in Python? Any code suggestions will be appreciated.
jfhbrook commented
You should be able to do that here:
# my_events.py
from pyee.base import EventEmitter
ee = new EventEmitter
# a.py
from my_events import ee
ee.emit('lol', {})
# b.py
from my_events import ee
ee.on('lol', print)
# __init__.py
import a
import b
Similar kind of mutability that you get with module.exports and require.
Going to close this since there's no real action to take on my part. Cheers!