feat: add Event.reset() to allow re-dispatching an event#23
Open
hartym wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #18.
Once a listener calls
stop_propagation(),propagation_stoppedstays set on the instance, so re-dispatching the same event runs only up to the first listener again. This addsEvent.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: addEvent.reset().tests/test_basic.py: cover reset and reuse-after-stop.CHANGELOG.rst: add theEvent.reset()entry to the Unreleased section.Tests pass (48), ruff lint and format clean.