concise publish/subscribe utility
Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
tests
.coveragerc
.gitignore
.travis.yml
LICENSE
README
README.rst
setup.py
smoke.py
test-requirements.txt

README.rst

smoke

https://img.shields.io/pypi/v/smoke.svg?style=flat https://img.shields.io/travis/keis/smoke.svg?style=flat https://img.shields.io/coveralls/keis/smoke.svg?style=flat

A concise Publish/Subscribe utility module. It supports both free-form signal names and a stricter style where signals are declared first. You can also mix them.

Usage

import smoke

class MyCls(smoke.Broker):
    appears = smoke.signal('appears')
    leaves = smoke.signal('leaves')

def say_hello(what):
    print("hello %s" % (what,))

def say_goodbye(what):
    print("good bye %s" % (what,))

# Using broker
o = MyCls()
o.subscribe("appears", say_hello)
o.publish("appears", what='world')

# Using declared signals
o = MyCls()
o.leaves.subscribe(say_goodbye)
o.leaves.publish(what='world')

# Mixing
o = MyCls()
o.subscribe("appears", say_hello)
o.appears.publish()