-
Notifications
You must be signed in to change notification settings - Fork 328
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
handle_on for args with triggers #852
Comments
@lo5 |
Thanks for taking the time to provide a repro! Help me understand the bug:
Here, Changing |
I don't think it is a bug either but an improvement. If we change I am looking for a way to invoke |
OK. I understand this better now - thanks for the explanation. Changing the predicate signature from Changing the predicate signature from The example above is a corner case that cannot be handled by the What do you think? |
Something like this: @app('/')
async def serve(q: Q):
await initialize_client(q)
if q.user.dark_mode != q.args.dark_mode:
await dark_mode(q)
return
await handle_on(q)
|
I like that. |
Thanks for your inputs, @srini-x! I'll leave this open for now, but deprioritize. |
I see this as closely related to #1484 (comment) , where the app wants to know which component changed in order to update the state correctly. Consider two form components, where the state of each affects the other.
In the current framework, both states get passed in
To deal with this, I route all triggers to a central handler that then compares each The suggestion in #1484 (comment) to include the triggered component in events would simplify this considerably. The suggestion above to include I think signaling which component was triggered (#1484 (comment)) is the simpler, more straightforward approach. I can imagine cases where adding Q in the predicate would allow more complex routing of trigger handlers, but I don't have any need for those hypothetical cases. |
Wave SDK Version, OS
Wave 0.16.0, OS agnostic
Actual behavior
Following code triggers
dark_mode
instead ofclick_me
trigger for the toggle is implemented like this:
@on('dark_mode', lambda x: isinstance(x, bool))
Code
Video of the broken output
click_me_broken.mp4
Expected behavior
Trigger dark_mode only when dark_mode is toggled. Clicking the
Click Me
button should increment the count as shown in the video below.click_me.mp4
Steps To Reproduce
dark_mode.py
A proposal
Pass
q
to the predicate on this linewave/py/h2o_wave/routing.py
Line 113 in f7a9922
changing it to
if predicate(q, arg_value):
Change the app code from above to
The text was updated successfully, but these errors were encountered: