Skip to content

Commit ed4ec10

Browse files
Add documentation for temporal event action (#1314)
* Add documentation for temporal event action Co-Authored-By: Alek Petuskey <[email protected]> * Address PR feedback: Fix version, remove contractions, use rx.moment example Co-Authored-By: Alek Petuskey <[email protected]> * Revert changes to pcweb/whitelist.py as requested in PR review Co-Authored-By: Alek Petuskey <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alek Petuskey <[email protected]>
1 parent 47ffaa8 commit ed4ec10

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/events/event_actions.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,44 @@ updated default_value from the state.
209209
Without the `key` set, the slider would always display the original
210210
`settled_value` after a page reload, instead of its current value.
211211
```
212+
213+
## Temporal Events
214+
215+
_Added in [v0.6.6](https://github.com/reflex-dev/reflex/releases/tag/v0.6.6)_
216+
217+
### temporal
218+
219+
The `.temporal` action prevents events from being queued when the backend is down.
220+
This is useful for non-critical events where you do not want them to pile up if there is
221+
a temporary connection issue.
222+
223+
```md alert warning
224+
# Temporal events are discarded when the backend is down.
225+
226+
When the backend is unavailable, events with the `.temporal` action will be
227+
discarded rather than queued for later processing. Only use this for events
228+
where it is acceptable to lose some interactions during connection issues.
229+
```
230+
231+
In the following example, the `rx.moment` component with `interval` and `on_change` uses `.temporal` to
232+
prevent periodic updates from being queued when the backend is down:
233+
234+
```python demo exec
235+
class TemporalState(rx.State):
236+
current_time: str = ""
237+
238+
@rx.event
239+
def update_time(self):
240+
self.current_time = datetime.datetime.now().strftime("%H:%M:%S")
241+
242+
def temporal_example():
243+
return rx.vstack(
244+
rx.heading("Current Time:"),
245+
rx.heading(TemporalState.current_time),
246+
rx.moment(
247+
interval=1000,
248+
on_change=TemporalState.update_time.temporal,
249+
),
250+
rx.text("Time updates will not be queued if the backend is down."),
251+
)
252+
```

0 commit comments

Comments
 (0)