Skip to content

Commit b03db90

Browse files
Add interactive demo examples for async computed vars
Co-Authored-By: Alek Petuskey <alek@pynecone.io>
1 parent 93a1067 commit b03db90

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/vars/computed_vars.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Async computed vars are useful for operations that require asynchronous processi
102102
- File I/O operations
103103
- Any other operations that benefit from async/await
104104

105-
```python
105+
```python demo exec
106106
class AsyncVarState(rx.State):
107107
count: int = 0
108108

@@ -123,6 +123,7 @@ def async_var_example():
123123
rx.text(f"Count: {AsyncVarState.count}"),
124124
rx.text(f"Delayed count (x2): {AsyncVarState.delayed_count}"),
125125
rx.button("Increment", on_click=AsyncVarState.increment),
126+
spacing="4",
126127
)
127128
```
128129

@@ -134,7 +135,7 @@ When the count changes, the async computed var is automatically recomputed.
134135
Just like regular computed vars, async computed vars can also be cached. This is especially
135136
useful for expensive async operations like API calls or database queries.
136137

137-
```python
138+
```python demo exec
138139
class AsyncCachedVarState(rx.State):
139140
user_id: int = 1
140141
refresh_trigger: int = 0

0 commit comments

Comments
 (0)