-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(InputBinding): subscribe callback now supports event priority #4211
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
base: main
Are you sure you want to change the base?
Conversation
95f1c08
to
b77ef5e
Compare
b77ef5e
to
157d489
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@@ -27,7 +28,7 @@ function valueChangeCallback( | |||
inputs: InputValidateDecorator, | |||
binding: InputBinding, | |||
el: HTMLElement, | |||
allowDeferred: boolean | |||
priority: InputPolicyOpts["priority"] |
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.
If I'm reading the source correctly, InputPolicyOpts["priority"]
is the same as EventPriority
, right? If so, I think the second option is clearer because it doesn't require redirecting through InputPolicyOpts
This explanation is the first time I've seen If we're updating the API, I'd love to push it in a direction that supports a more readable interface. I.e. in addition to backcompat for callback(true)
callback({ priority: "deferred" })
callback(false)
callback({ priority: "immediate" })
// or now also
callback({priority: "event"}) |
Until now, custom input bindings could only pass a boolean value to their subscribe callback. That is, they all do something similar to this to notify Shiny of a change:
These boolean values effectively map to values of
priority: "deferred"
(true
) andpriority: "immediate"
(false
).This means, if an input wants to resend their value immediately regardless of whether the value has changed (i.e.,
priority: "event"
), that isn't possible (until now).The motivator for adding this is for
input_submit_textarea()
in rstudio/bslib#1204, where it feels like the most desirable behavior is to always resend immediately.