Skip to main content

Python port of d3-dispatch

Project description

pyd3js-dispatch

PyPI version Python versions License CI Security

Python port of d3-dispatch.

Tracked version: see upstream_lock.json.

What is a dispatch?

A dispatch is a small, namespaced event-listener registry. You create it with a fixed set of event types (e.g. "start", "end"), attach callbacks via .on("type.namespace", fn), and later trigger all callbacks of a type via .call("type", that, *args) / .apply("type", that, args).

This pattern is used throughout D3 to provide internal events (drag/zoom/brush/transition, etc.) without requiring a DOM or a heavyweight event system.

What you get

  • Upstream export parity (for the pinned d3-dispatch@3.0.1): the compatibility matrix below covers every upstream export; nothing is marked [missing].
  • 100% Python test coverage for pyd3js_dispatch (run the coverage command below).

Install

From PyPI:

pip install pyd3js-dispatch

This repo is a uv workspace monorepo. For local development:

uv sync --group dev

Usage

import pyd3js_dispatch as dd

d = dd.dispatch("start", "end")
log: list[tuple[str, int]] = []

d.on("start.foo", lambda this, x: log.append(("foo", x)))
d.call("start", None, 1)
print(log)

d.on("start.foo", None)
d.call("start", None, 2)
print(log)
[('foo', 1)]
[('foo', 1)]

Compatibility matrix (pinned upstream)

  • dispatch — [unit]

Development

Coverage:

uv run pytest packages/pyd3js-dispatch/tests --cov=pyd3js_dispatch --cov-report=term-missing

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

pyd3js_dispatch-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyd3js_dispatch-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pyd3js_dispatch-0.1.0.tar.gz.

File metadata

  • Download URL: pyd3js_dispatch-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyd3js_dispatch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 70bcbd711aea572e0c0752da08c37655b95c2136fbeef07e9ff5beff375ee51d
MD5 d82932bdc563402feac79d7ecf7dd11a
BLAKE2b-256 f27703970de2e8664e2f710b637814d23167c80f2a411bbaff2a3c708d653f8d

See more details on using hashes here.

File details

Details for the file pyd3js_dispatch-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyd3js_dispatch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc4b1cd1fa51155db54cbd74034ffddffca03bb09478328f7b34a2692149d912
MD5 77cd9ea22cbe07115a2165cc67c71d46
BLAKE2b-256 ba731e361ca62ff54c79710b8f71b479739038546f60fe821dd0afc7ebee1abd

See more details on using hashes here.

Supported by

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