@jsenv/navi 0.29.114 → 0.29.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jsenv_navi.js +38 -46
- package/dist/jsenv_navi.js.map +7 -8
- package/docs/actions.md +14 -0
- package/docs/create_and_edit.md +3 -1
- package/package.json +1 -1
package/docs/actions.md
CHANGED
|
@@ -97,6 +97,20 @@ it — and why a run settles with its error rather than rejecting — is
|
|
|
97
97
|
state at once — `{ idle, loading, completed, aborted, error, data, params }` —
|
|
98
98
|
for a component that needs to look at it rather than render it.
|
|
99
99
|
|
|
100
|
+
**Reading does not run.** `useAsyncData` waits for data someone else asked for
|
|
101
|
+
— for a page, the route, through `routeAction`. A component reading an action
|
|
102
|
+
that nobody ran suspends, and `<Loading>` draws nothing for an idle action (no
|
|
103
|
+
spinner for a request nobody sent): the whole subtree stays blank, for good. The
|
|
104
|
+
obvious fix does not work — a `useEffect` in that same component that would
|
|
105
|
+
`run()` it never fires, because a suspended component has no effects, and the
|
|
106
|
+
run it was about to start is exactly what the suspension waits for. So either
|
|
107
|
+
the action is started **before** anything reads it — bound where the screen is
|
|
108
|
+
decided: a `routeAction`, a `<Button action>`, the `action` of the `<Link>` one
|
|
109
|
+
came in by — or the component owns its request and does not suspend on it: a
|
|
110
|
+
folding panel, a slice a button asks for. That one reads `action.dataSignal` and
|
|
111
|
+
`action.errorSignal` (or `useActionStatus`) directly, `run()`s the action from an
|
|
112
|
+
effect, and draws its own skeleton until the data is there.
|
|
113
|
+
|
|
100
114
|
`{ onLoad }` is what the screen does with the data **once, when it becomes
|
|
101
115
|
known** — seed the fields someone is about to edit, focus something, remember
|
|
102
116
|
where a list was:
|
package/docs/create_and_edit.md
CHANGED
|
@@ -134,7 +134,9 @@ Two things to know or the screen stays empty:
|
|
|
134
134
|
- **Reading an action does not start it.** `useAsyncData` waits for data
|
|
135
135
|
someone else asked for; what asks is the route (`routeAction`). A component
|
|
136
136
|
reading an action nobody runs suspends forever, and the whole `<Loading>`
|
|
137
|
-
subtree stays blank
|
|
137
|
+
subtree stays blank — and an effect in that component cannot rescue it, a
|
|
138
|
+
suspended component has no effects. What to do instead is under "Reading an
|
|
139
|
+
action" in [actions.md](./actions.md#reading-an-action).
|
|
138
140
|
- **Handle the error where it happens**, or hand it to an `<ErrorBoundary>`:
|
|
139
141
|
`useAsyncData(action, { loading: true, error: true })` returns
|
|
140
142
|
`[data, loading, error]`, which is what lets a page draw its own "the server
|