Skip to content

feat: add Event.reset() to allow re-dispatching an event#23

Open
hartym wants to merge 2 commits into
mainfrom
feat/event-reset
Open

feat: add Event.reset() to allow re-dispatching an event#23
hartym wants to merge 2 commits into
mainfrom
feat/event-reset

Conversation

@hartym
Copy link
Copy Markdown
Member

@hartym hartym commented Jun 5, 2026

Closes #18.

Once a listener calls stop_propagation(), propagation_stopped stays set on the instance, so re-dispatching the same event runs only up to the first listener again. This adds Event.reset() to clear that state, making an event instance reusable across dispatches.

Non-breaking: the default behaviour is unchanged and reuse is opt-in. The broader option of resetting propagation at the start of every dispatch is tracked for 3.0 in #24.

  • whistle/event.py: add Event.reset().
  • tests/test_basic.py: cover reset and reuse-after-stop.
  • CHANGELOG.rst: add the Event.reset() entry to the Unreleased section.

Tests pass (48), ruff lint and format clean.

Event.reset() clears propagation_stopped so the same event instance can
be dispatched again after an intermediate listener stopped propagation.
Non-breaking: default behaviour is unchanged and reuse is opt-in.

Closes #18
Merge the Event.reset() entry into the existing Unreleased section instead
of replacing the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop propagation makes events non-reusable

1 participant