Skip to content
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

Add socket_id to UIEventArguments; use new client.target where possible #4335

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

falkoschindler
Copy link
Contributor

@falkoschindler falkoschindler commented Feb 10, 2025

This PR addresses issue #4016 and feature request #4218:

  • UI events should provide a socket ID to be used with the client.individual_target context.
  • ui.navigate, ui.download() and ui.notify() should adhere to the client.individual_target context.
  • ui.download() on the auto-index page (without using client.individual_target) should raise an exception.

Unfortunately, the current implementation has one main drawback:

  • The new socket ID argument affects all existing event argument classes. Therefore this change might break existing use code.

The PR is still a draft because we're thinking about alternative solutions, like automatically calling event handlers in the context of the current socket. This would automatically trigger notifications, downloads and navigations on the socket that caused the event. But it could also affect run_method() and run_javascript() calls, which might not be desired.

@falkoschindler falkoschindler added the enhancement New feature or request label Feb 10, 2025
@falkoschindler
Copy link
Contributor Author

In f7d3fb7 I added a default '' to the socket_id field and removed it from the initializer. This way existing user code doesn't break when initializing event arguments without socket ID, and Python 3.8 and 3.9 don't complain about the order of positional and keyword arguments in derived classed. Given the limitations of dataclasses in Python <=3.9, I'm rather pleased with this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant