You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/guide/application.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,19 @@ tokio::spawn(async move {
42
42
});
43
43
```
44
44
45
+
### Fetching state
46
+
47
+
Sometimes you need to read the current state without mutating it — for example, to check a condition before deciding what to do next. `fetch()` sends a read closure into the event loop and returns a `oneshot::Receiver<T>` with the result:
Like `update()`, the closure runs on the event loop, so it sees a consistent snapshot of state. The returned receiver is `.await`-ed to get the value. Because `fetch()` does not mutate state, it does not trigger a re-render.
57
+
45
58
### Batching
46
59
47
60
Multiple `update()` calls between frames are batched into a single rebuild. This means you can call `update()` rapidly without causing unnecessary re-renders:
0 commit comments