Sfoglia il codice sorgente

Find a rate policy balance

shiny-input
Garrick Aden-Buie 6 anni fa
parent
commit
8519d729bc
2 ha cambiato i file con 18 aggiunte e 3 eliminazioni
  1. +15
    -0
      inst/shiny-input-app/dev-shiny-input.Rmd
  2. +3
    -3
      inst/shiny-input-app/typing.js

+ 15
- 0
inst/shiny-input-app/dev-shiny-input.Rmd Vedi File

@@ -439,3 +439,18 @@ How does the app report the initial typing speed rates?

Add another `if` statement to continue to return `null`
until there are at least 3 words in the text box.

### Your Turn: Find a rate policy balance

At this point,
we are streaming values straight from the browser to the server.
This is probably a bit much.

Change `callback()` to `callback(true)` in `subscribe()`.

Try various settings of

- `policy`: `debounce`, `throttle` or `direct`.

Find a good delay rate.


+ 3
- 3
inst/shiny-input-app/typing.js Vedi File

@@ -68,13 +68,13 @@ $.extend(typingSpeed, {
// If using callback(true) the rate policy applies,
// for example if you need to throttle or debounce
// the values being sent back to the server.
callback();
callback(true);
});
},
getRatePolicy: function() {
return {
policy: 'debounce', // 'debounce', 'throttle' or 'direct' (default)
delay: 100 // milliseconds for debounce or throttle
policy: 'throttle', // 'debounce', 'throttle' or 'direct' (default)
delay: 1000 // milliseconds for debounce or throttle
};
},
unsubscribe: function(el) {

Loading…
Annulla
Salva