Skip to main content

Micropython compatible producer/subscriber event bus system with optional threading.

Project description

micropython-event-bus

Micropython producer/subscriber event system with optional threading

Note that this package is early stages so could have undocumented bugs.

The not-so-magic school bus

Installation

pip3 install micropython-event-bus

or Clone this repository into your project:

git clone https://github.com/jaycosaur/micropython-event-bus

Usage

from micropython_event_bus import Producer, subscribe

# setup simple producer
my_producer = Producer(name="my first producer")

# create subscriber
# with decorator
@subscribe(my_producer)
def my_subscriber(*args, **kwargs):
    print('I got a message!')

# or by calling the producer subscribe method
def my_second_subscriber(*args, **kwargs):
    print('I also got a message!')

my_producer.subscribe(my_second_subscriber)

# emit event

# from producer via __call__ method
my_producer(1,2,3,4)
# or by calling emit directly
my_producer.emit(1,2,3,4)

For more examples please refer to the examples

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for micropython-event-bus, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size micropython_event_bus-0.0.4-py3-none-any.whl (4.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size micropython_event_bus-0.0.4.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page