
Event handler wrappers
event-wrappers.RdControl how event callbacks are dispatched from the browser to the server.
Usage
event_immediate(fn, coalesce = FALSE, prevent_default = FALSE)
event_throttle(
fn,
ms,
leading = TRUE,
coalesce = TRUE,
prevent_default = FALSE
)
event_debounce(fn, ms, coalesce = TRUE, prevent_default = FALSE)Arguments
- fn
An event handler function receiving
(event)or(event, id).- coalesce
If
TRUE, gate on server idle so events never queue faster than the server can process them. Defaults toFALSEforevent_immediate()andTRUEforevent_throttle()/event_debounce().- prevent_default
If
TRUE, callevent.preventDefault()in the browser before dispatching. Defaults toFALSE.- ms
Minimum interval (throttle) or quiet period (debounce) in milliseconds.
- leading
If
TRUE(default), fire immediately on the first event. IfFALSE, wait for the timer before firing.
Details
event_immediate(): Fires on every event with no rate limiting. Bare functions passed as event handlers are implicitly wrapped withevent_immediate().event_throttle(): Fires at most everymsmilliseconds while the event is active.event_debounce(): Waits until the user pauses formsmilliseconds before firing.
The event object
The event argument passed to handlers is a list containing all
primitive-valued properties (string, numeric, logical) from the browser
event object, plus these element properties:
valueThe element's current value (character).
valueAsNumberNumeric value of the element, or
NAif the input is empty or non-numeric (e.g. a blank text box). Useful for range and number inputs.checkedLogical, for checkbox and radio inputs.
Keyboard events additionally include key, code, ctrlKey,
shiftKey, altKey, and metaKey.