/emits

A simple Event Emitter for python

Primary LanguagePythonMIT LicenseMIT

emits

A simple Event Emitter for Python

Install

pip install emits

Usage

from emits import EventEmitter

emits = EventEmitter()

API

emits.on(event_name, callback) or emits.add_event_listner(event_name, callback)

Register an event listener for the given event_name which uses the defined callback function to consume the data it receives

Example

def callback(data):
    print(data)

emits.on("test add_event_listener", callback)
emits.emit("test add_event_listener", "test data")

emits.once(event_name, callback) or emits.add_event_listener_once(event_name, callback)

Register an event listener for the given event_name which uses the defined callback function to consume the data it receives only once

emits.off(event_name) or emits.remove_event_listener(event_name)

Turn off an event listener created by emits.on() or emits.add_event_listener()