Skip to content

Commit

Permalink
Update throttle docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 27, 2024
1 parent e0bf4be commit 10ef28f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions reactiveweb/src/throttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ import { cell, resource } from 'ember-resources';
* A utility that creates a resource allowing us to throttle execution of a function.
* Especially useful for rate limiting execution of handlers on events like resize and scroll.
*
* ```js
* import Component from '@glimmer/component';
* import { tracked } from '@glimmer/tracking';
* import { use } from 'ember-resources';
* import { throttle } from 'reactiveweb/throttle';
*
* const delay = 100; // ms
*
* class Demo extends Component {
* @tracked _userInput = 'initial';
*
* // immediately returns 'initial', and all updates will be throttled
* // to update only after 100ms since the last value was detected.
* @use userInput = throttle(100, () => this._userInput);
* ```
*
* @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
* @param callback A function to be executed after delay milliseconds.
*/
Expand Down

0 comments on commit 10ef28f

Please sign in to comment.