-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Implement decentralized event handlers #5211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
devin-ai-integration
wants to merge
11
commits into
main
from
devin/1745972901-decentralized-event-handlers
Closed
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
507042a
Implement decentralized event handlers
devin-ai-integration[bot] 9601b0d
Fix decentralized event handlers with parameters
devin-ai-integration[bot] ee11e1a
make ci run
adhami3310 9cc0ae5
Fix _get_event_handler to maintain backward compatibility
devin-ai-integration[bot] e1d07b4
Fix docstring for wrap_decentralized_handler
devin-ai-integration[bot] 5825564
Fix parameter handling for decentralized event handlers
devin-ai-integration[bot] 876c8e4
Fix decentralized event handlers with parameters
devin-ai-integration[bot] f12a9c7
Fix decentralized event handler marker preservation
devin-ai-integration[bot] 6583f92
Add simple test for decentralized event handlers with proper docstrings
devin-ai-integration[bot] dde12b7
Fix decentralized event handler marker preservation
devin-ai-integration[bot] 6e98a68
Move test_decentralized_handlers_simple.py to tests/units directory
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """Simple test for decentralized event handlers.""" | ||
|
|
||
| import reflex as rx | ||
|
|
||
|
|
||
| class TestState(rx.State): | ||
| """Test state class for decentralized event handlers.""" | ||
|
|
||
| count: int = 0 | ||
|
|
||
|
|
||
| @rx.event | ||
| def reset_count(state: TestState): | ||
| """Reset the count to zero. | ||
|
|
||
| Args: | ||
| state: The test state to modify. | ||
| """ | ||
| state.count = 0 | ||
|
|
||
|
|
||
| @rx.event | ||
| def set_count(state: TestState, value: str): | ||
| """Set the count to a specific value. | ||
|
|
||
| Args: | ||
| state: The test state to modify. | ||
| value: The value to set as count. | ||
| """ | ||
| state.count = int(value) | ||
|
|
||
|
|
||
| def test_is_decentralized(): | ||
| """Test if functions are correctly identified as decentralized event handlers.""" | ||
| from reflex.event import is_decentralized_event_handler, wrap_decentralized_handler | ||
|
|
||
| assert is_decentralized_event_handler(reset_count) | ||
|
|
||
| wrapped = wrap_decentralized_handler(reset_count) | ||
| assert is_decentralized_event_handler(wrapped) | ||
|
|
||
| assert is_decentralized_event_handler(set_count) | ||
| wrapped_with_params = wrap_decentralized_handler(set_count) | ||
| assert is_decentralized_event_handler(wrapped_with_params) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_is_decentralized() |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong directory :(