Skip to main content

A simple events handler package.

Project description

Dyspatch

A simple package that implements basic events handling in Python.

Installation

pip install dyspatch

Usage

A basic example is as follows:

import dyspatch

users = []

def on_room_join(user):
    print(f'{user} joined the room.')
    users.append(user)
    print(f'We now have {len(users)} users')

events = dyspatch.Events()
events.add_listener('room_join', on_room_join)
events.dispatch('room_join', args=['Alex'])
events.dispatch('room_join', args=['Bob'])

The output is like this:

Alex joined the room.
We now have 1 users
Bob joined the room.
We now have 2 users

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dyspatch-0.0.1-py3-none-any.whl (3.8 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