Преглед изворни кода

Find a rate policy balance

shiny-input
Garrick Aden-Buie пре 6 година
родитељ
комит
8519d729bc
2 измењених фајлова са 18 додато и 3 уклоњено
  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 Прегледај датотеку



Add another `if` statement to continue to return `null` Add another `if` statement to continue to return `null`
until there are at least 3 words in the text box. 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 Прегледај датотеку

// If using callback(true) the rate policy applies, // If using callback(true) the rate policy applies,
// for example if you need to throttle or debounce // for example if you need to throttle or debounce
// the values being sent back to the server. // the values being sent back to the server.
callback();
callback(true);
}); });
}, },
getRatePolicy: function() { getRatePolicy: function() {
return { 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) { unsubscribe: function(el) {

Loading…
Откажи
Сачувај