@@ -23,7 +23,7 @@ submitted, close a menu, clear an error), give it its own instant: `onFlush(() =
2323compiler can't tell a reset from a write that should wait with the rest, such as a tab highlight that moves with its
2424page, so it's your call. Decide it for each write that sits next to work that loads.
2525
26- ```
26+ ``` rx
2727// submit a todo: the input clears now, the row shows as a guess until the server answers
2828let t = text
2929onFlush(() => { text := "" })
@@ -32,7 +32,7 @@ addTodo(t)
3232
3333## 1. Reading from the server: an equation
3434
35- ```
35+ ``` rx
3636forecast = city == "" ? null : city.length < 3 ? throw TooShort(city) : await fetchForecast(city)
3737```
3838
@@ -59,7 +59,7 @@ forecast = city == "" ? null : city.length < 3 ? throw TooShort(city) : await fe
5959
6060## 3. Writing to the server: an action
6161
62- ```
62+ ``` rx
6363export source profile: Profile = await loadProfile() // a source with a question: it can take a guess
6464export source saveError: string = ""
6565
@@ -95,7 +95,7 @@ by what the screen should do:
9595
9696When several actions can each change a different row of one list, guess the row, not the list:
9797
98- ```
98+ ``` rx
9999export source todos: Todo[] key id = await loadTodos()
100100
101101export action markDone(id: number) {
@@ -136,7 +136,7 @@ A guess on a value whose question reads a selection holds the selection with it:
136136something else waits for the server, and the screen stays on the old choice until the action ends (F-1). Keep the
137137pending items in a source of their own, with a constant question, and show them beside the loaded ones:
138138
139- ```
139+ ``` rx
140140source photo: number := 1
141141tags = await loadTags(photo)
142142source adding: { photo: number; tag: string }[] = []
@@ -169,7 +169,7 @@ and the screen reads only the top:
169169
170170` examples/todos.rx ` is the whole app:
171171
172- ```
172+ ``` rx
173173server = await loadTodos() // 1. what the server has: re-asked after every write
174174source failures: Failure[] := [] // outlives a reset: kept until a retry is accepted
175175source todos: Row[] key id = withFailures(server, failures) // 2. the client's layer; 3. row guesses go on it
0 commit comments