Skip to content

Commit 54d3bd2

Browse files
committed
docs: add to example docs
1 parent 2fae5ff commit 54d3bd2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

reactiveweb/src/debounce.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ class TrackedValue<T> {
5454
* @use search = RemoteData(() => `https://my.domain/search?q=${this.debouncedInput}`);
5555
* }
5656
* ```
57+
*
58+
* @example
59+
* An initialize value can be provided as the starting value instead of it initially returning undefined.
60+
* ```js
61+
* import Component from '@glimmer/component';
62+
* import { tracked } from '@glimmer/tracking';
63+
* import { use } from 'ember-resources';
64+
* import { debounce } from 'reactiveweb/debounce';
65+
*
66+
* const delay = 100; // ms
67+
*
68+
* class Demo extends Component {
69+
* @tracked userInput = 'products';
70+
*
71+
* @use debouncedInput = debounce(delay, () => this.userInput, this.userInput);
72+
* }
73+
* ```
5774
*
5875
* @param {number} ms delay in milliseconds to wait before updating the returned value
5976
* @param {() => Value} thunk function that returns the value to debounce

0 commit comments

Comments
 (0)