add event_action flags to rx.event decorator#5574
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Greptile Summary
This PR introduces a significant enhancement to the @rx.event decorator, allowing event action flags to be specified directly in the decorator rather than through method chaining. This change improves code readability and maintainability while maintaining backward compatibility.
The changes include:
- Adding support for event action parameters directly in the decorator (
stop_propagation,prevent_default,throttle,debounce, andtemporal) - Fixing a bug in event_actions dictionary merging order to ensure correct precedence
- Enhancing the
_create_event_handlermethod to handle decorator-attached event actions
Before:
MyState.handler.stop_propagation().throttle(500)After:
@event(stop_propagation=True, throttle=500)
def handler(self):
passConfidence score: 5/5
- This PR is very safe to merge as it adds new functionality without breaking existing behavior
- Score is 5 because the changes are well-tested, maintain backward compatibility, and fix an existing bug in event action precedence
- The changes are focused and well-contained within the event handling system
3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
CodSpeed Performance ReportMerging #5574 will not alter performanceComparing Summary
|
masenf
approved these changes
Jul 16, 2025
| prevent_default: Whether to prevent the default behavior of the event. | ||
| throttle: Throttle the event handler to limit calls (in milliseconds). | ||
| debounce: Debounce the event handler to delay calls (in milliseconds). | ||
| temporal: Whether the event should be temporal. |
Collaborator
There was a problem hiding this comment.
Suggested change
| temporal: Whether the event should be temporal. | |
| temporal: Whether the event should be dropped when the backend is down. |
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.
Allow to attach default value for event actions flag on an event_handler decorated by
@rx.eventcloses #5441