Skip to main content

ADI integration for pymitter

Project description

Pymitter Integration

Adds the ability to inject an instance of EventEmitter from pymitter. This instance will be shared within a context (separate threads have separate emitters). Registration is done via the entry point in autoinject, so no need to do anything other than install this package.

from autoinject import injector as _injector
import pymitter


class NeedsEvents:

    ee: pymitter.EventEmitter = None

    @_injector.construct
    def __init__(self):
        pass

    def do_stuff(self):
        self.ee.emit("foo.bar", "hello world")


class LikesEvents:

    ee: pymitter.EventEmitter = None

    @_injector.construct
    def __init__(self):
        self.ee.on("foo.bar", self.on_event)

    def on_event(self, arg):
        print("foo bar emitted: {}".format(arg))


emitter = NeedsEvents()
receiver = LikesEvents()

emitter.do_stuff()
# OUTPUT: foo bar emitted: hello world        

Project details


Download files

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

Source Distribution

autoinject_pymitter-1.0.0.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

autoinject_pymitter-1.0.0-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page