Skip to content

Commit

Permalink
Improve polling example [deploy-site]
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Jan 21, 2025
1 parent 76758f3 commit b859ced
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion site/static/md/examples/polling.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@
</div>
```

You can use the [`data-on-interval`](/reference/attribute_plugins#data-on) attribute to execute an expression at a regular interval. In this example, we are incrementing the `count` signal every 1 second.
You can use the [`data-on-interval`](/reference/attribute_plugins#data-on) attribute to execute an expression at a regular interval. In this example, we are incrementing the `count` signal every 1 second.

An alternative approach is use the [`data-on-load`](/reference/attribute_plugins#data-on) attribute with the `__delay` modifier to control the polling frequency from the backend. Using this method, you can control back-pressure.

```html
<div data-on-load__delay.1s="@get('/endpoint')">
Count: 0
</div>
```

The backend endpoint can merge the same fragment but with a different delay value to determine the polling frequency.

0 comments on commit b859ced

Please sign in to comment.