Conversation
…to remove Label component use and replace with Paragraph
| The `Debouncer` runs on the UI thread using webforJ's [`Interval`](/docs/advanced/interval) mechanism, so you don't need to wrap UI updates in `Environment.runLater()`. | ||
|
|
||
| :::tip | ||
| The delay parameter uses seconds as the unit, not milliseconds. Use `0.3f` for 300ms or `1.5f` for 1.5 seconds. |
There was a problem hiding this comment.
🚫 [vale] reported by reviewdog 🐶
[Google.Units] Put a nonbreaking space between the number and the unit in '300ms'.
| }); | ||
| ``` | ||
|
|
||
| ## Debouncer vs ElementEventOptions {#debouncer-vs-elementeventoptions} |
There was a problem hiding this comment.
[Google.Headings] 'Debouncer vs ElementEventOptions' should use sentence-style capitalization.
|
|
||
| ## Best practices {#best-practices} | ||
|
|
||
| 1. **Choose appropriate delays**: Use shorter delays (200-300ms) for responsive interactions like search, and longer delays (1-2s) for expensive operations like auto-save. |
There was a problem hiding this comment.
🚫 [vale] reported by reviewdog 🐶
[Google.Units] Put a nonbreaking space between the number and the unit in '300ms'.
|
|
||
| ## Best practices {#best-practices} | ||
|
|
||
| 1. **Choose appropriate delays**: Use shorter delays (200-300ms) for responsive interactions like search, and longer delays (1-2s) for expensive operations like auto-save. |
There was a problem hiding this comment.
🚫 [vale] reported by reviewdog 🐶
[Google.Units] Put a nonbreaking space between the number and the unit in '2s'.
|
|
||
| 2. **Reuse debouncer instances**: Create one `Debouncer` instance and reuse it rather than creating new instances on each event. | ||
|
|
||
| 3. **Flush before critical actions**: Call `flush()` before form submission or navigation to ensure pending actions complete. |
There was a problem hiding this comment.
[webforJ.BeDirect] Avoid using 'ensure pending'. Focus more on explicitly giving details about the feature.
|
@MatthewHawkins I see some unrelated changes in the PR and a version change in the POM. Please clean that up and mark the PR as ready for review when it's done. |
| @@ -0,0 +1,196 @@ | |||
| --- | |||
| sidebar_position: 11 | |||
|
|
||
| The `Debouncer` runs on the UI thread using webforJ's [`Interval`](/docs/advanced/interval) mechanism, so you don't need to wrap UI updates in `Environment.runLater()`. | ||
|
|
||
| :::tip |
| The delay parameter uses seconds as the unit, not milliseconds. Use `0.3f` for 300ms or `1.5f` for 1.5 seconds. | ||
| ::: | ||
|
|
||
| ## API methods {#api-methods} |
There was a problem hiding this comment.
Remove the API methods section. You already cover them later.
|
|
||
| The following methods can be used to more precisely handle the execution and use of the `Debouncer`: | ||
|
|
||
| ### Cancelling a pending action {#cancelling-a-pending-action} |
There was a problem hiding this comment.
Explain that, like intervals. It's good practice to cancel the interval when the component is destroyed.
| } | ||
| ``` | ||
|
|
||
| ## Use cases {#use-cases} |
| ``` | ||
|
|
||
| ## Debouncer vs ElementEventOptions {#debouncer-vs-elementeventoptions} | ||
|
|
There was a problem hiding this comment.
Rename section to Choosing between Debouncer and event debounce options
| }, options); | ||
| ``` | ||
|
|
||
| ## Best practices {#best-practices} |
| private final TextField input = new TextField(); | ||
| private final Paragraph output = new Paragraph(); | ||
| private final Paragraph counter = new Paragraph(); | ||
| private final Debouncer debounce = new Debouncer(0.5f); |
There was a problem hiding this comment.
Cancel the debouncer when component is destroyed
| count++; | ||
| counter.setText("Key events: " + count); | ||
|
|
||
| debounce.run(() -> { |
No description provided.