@@ -29,7 +29,8 @@ function defaultReceiveMessage(el, { configuration, value }) {
2929
3030const defaultOptions = {
3131 receiveMessage : defaultReceiveMessage ,
32- type : false
32+ type : false ,
33+ ratePolicy : null
3334} ;
3435
3536/**
@@ -55,6 +56,18 @@ const defaultOptions = {
5556 * instance and passed a single argument, the input's containing DOM
5657 * element. The function should return either `false` or a string
5758 * corresponding to the type parameter of shiny::registerInputHandler().
59+ * - ratePolicy: A rate policy object as defined in the documentation for
60+ * getRatePolicy(): https://shiny.rstudio.com/articles/building-inputs.html
61+ * A rate policy object has two members:
62+ * - `policy`: Valid values are the strings "direct", "debounce", and
63+ * "throttle". "direct" means that all events are sent immediately.
64+ * - `delay`: Number indicating the number of milliseconds that should be
65+ * used when debouncing or throttling. Has no effect if the policy is
66+ * direct.
67+ * The specified rate policy is only applied when `true` is passed as the
68+ * second argument to the `setValue` function passed as a prop to the
69+ * input component.
70+ *
5871 */
5972export function reactShinyInput ( selector ,
6073 name ,
@@ -73,9 +86,9 @@ export function reactShinyInput(selector,
7386 getValue ( el ) {
7487 return this . getInputValue ( el ) ;
7588 }
76- setValue ( el , value ) {
89+ setValue ( el , value , rateLimited = false ) {
7790 this . setInputValue ( el , value ) ;
78- this . getCallback ( el ) ( ) ;
91+ this . getCallback ( el ) ( rateLimited ) ;
7992 this . render ( el ) ;
8093 }
8194 initialize ( el ) {
@@ -102,6 +115,9 @@ export function reactShinyInput(selector,
102115 throw new Error ( 'options.type must be false, a string, or a function' ) ;
103116 }
104117 }
118+ getRatePolicy ( ) {
119+ return options . ratePolicy ;
120+ }
105121
106122 /*
107123 * Methods not present in Shiny.InputBinding but accessible to users
0 commit comments