@solidjs/signals 2.0.0-beta.9 → 2.0.0-rc.0
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/README.md +13 -9
- package/dist/dev.js +5971 -1426
- package/dist/node.cjs +7681 -3293
- package/dist/prod/affects.js +126 -0
- package/dist/prod/boundaries.js +572 -0
- package/dist/prod/core/action.js +139 -0
- package/dist/prod/core/async.js +553 -0
- package/dist/prod/core/constants.js +92 -0
- package/dist/prod/core/context.js +67 -0
- package/dist/prod/core/core.js +817 -0
- package/dist/prod/core/dev.js +3 -0
- package/dist/prod/core/effect.js +145 -0
- package/dist/prod/core/error.js +68 -0
- package/dist/prod/core/external.js +98 -0
- package/dist/prod/core/graph.js +104 -0
- package/dist/prod/core/heap.js +140 -0
- package/dist/prod/core/invariants.js +42 -0
- package/dist/prod/core/lanes.js +140 -0
- package/dist/prod/core/optimistic.js +245 -0
- package/dist/prod/core/owner.js +302 -0
- package/dist/prod/core/scheduler.js +749 -0
- package/dist/prod/core/verdict.js +369 -0
- package/dist/prod/index.js +45 -0
- package/dist/prod/map.js +317 -0
- package/dist/prod/signals.js +375 -0
- package/dist/prod/store/optimistic.js +217 -0
- package/dist/prod/store/projection.js +231 -0
- package/dist/prod/store/reconcile.js +707 -0
- package/dist/prod/store/store.js +1081 -0
- package/dist/prod/store/storePath.js +103 -0
- package/dist/prod/store/utils.js +328 -0
- package/dist/types/affects.d.ts +47 -0
- package/dist/types/boundaries.d.ts +60 -13
- package/dist/types/core/action.d.ts +35 -6
- package/dist/types/core/async.d.ts +16 -1
- package/dist/types/core/constants.d.ts +35 -6
- package/dist/types/core/context.d.ts +10 -2
- package/dist/types/core/core.d.ts +58 -63
- package/dist/types/core/dev.d.ts +17 -2
- package/dist/types/core/effect.d.ts +1 -2
- package/dist/types/core/error.d.ts +33 -0
- package/dist/types/core/external.d.ts +0 -11
- package/dist/types/core/graph.d.ts +2 -1
- package/dist/types/core/heap.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/invariants.d.ts +59 -0
- package/dist/types/core/lanes.d.ts +2 -0
- package/dist/types/core/optimistic.d.ts +6 -0
- package/dist/types/core/owner.d.ts +50 -3
- package/dist/types/core/scheduler.d.ts +82 -10
- package/dist/types/core/types.d.ts +66 -1
- package/dist/types/core/verdict.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/map.d.ts +21 -5
- package/dist/types/signals.d.ts +164 -12
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +10 -6
- package/dist/types/store/reconcile.d.ts +31 -8
- package/dist/types/store/store.d.ts +101 -6
- package/dist/types-cjs/affects.d.cts +47 -0
- package/dist/types-cjs/boundaries.d.cts +60 -13
- package/dist/types-cjs/core/action.d.cts +35 -6
- package/dist/types-cjs/core/async.d.cts +16 -1
- package/dist/types-cjs/core/constants.d.cts +35 -6
- package/dist/types-cjs/core/context.d.cts +10 -2
- package/dist/types-cjs/core/core.d.cts +58 -63
- package/dist/types-cjs/core/dev.d.cts +17 -2
- package/dist/types-cjs/core/effect.d.cts +1 -2
- package/dist/types-cjs/core/error.d.cts +33 -0
- package/dist/types-cjs/core/external.d.cts +0 -11
- package/dist/types-cjs/core/graph.d.cts +2 -1
- package/dist/types-cjs/core/heap.d.cts +8 -0
- package/dist/types-cjs/core/index.d.cts +3 -2
- package/dist/types-cjs/core/invariants.d.cts +59 -0
- package/dist/types-cjs/core/lanes.d.cts +2 -0
- package/dist/types-cjs/core/optimistic.d.cts +6 -0
- package/dist/types-cjs/core/owner.d.cts +50 -3
- package/dist/types-cjs/core/scheduler.d.cts +82 -10
- package/dist/types-cjs/core/types.d.cts +66 -1
- package/dist/types-cjs/core/verdict.d.cts +2 -0
- package/dist/types-cjs/index.d.cts +3 -2
- package/dist/types-cjs/map.d.cts +21 -5
- package/dist/types-cjs/signals.d.cts +164 -12
- package/dist/types-cjs/store/index.d.cts +1 -1
- package/dist/types-cjs/store/optimistic.d.cts +3 -3
- package/dist/types-cjs/store/projection.d.cts +10 -6
- package/dist/types-cjs/store/reconcile.d.cts +31 -8
- package/dist/types-cjs/store/store.d.cts +101 -6
- package/package.json +11 -9
- package/dist/prod.js +0 -3627
package/README.md
CHANGED
|
@@ -107,12 +107,12 @@ const data = createMemo(async () => {
|
|
|
107
107
|
return response.json();
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
// Check async state
|
|
111
|
-
isPending(data); // true while
|
|
112
|
-
latest(data); // last resolved value
|
|
110
|
+
// Check async state for this read
|
|
111
|
+
isPending(data); // true while an unrevealed value change is in flight for this read
|
|
112
|
+
latest(data); // last resolved value; follows the not-ready path if no value has resolved yet
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
Use `action()`
|
|
115
|
+
Use `action()` for mutations — imperative async workflows whose writes span an async gap. Each invocation runs as a single transaction: every write between yields batches into one atomic update, and nothing commits until the action completes or the next `yield` resolves.
|
|
116
116
|
|
|
117
117
|
```typescript
|
|
118
118
|
const save = action(function* (item) {
|
|
@@ -120,6 +120,10 @@ const save = action(function* (item) {
|
|
|
120
120
|
});
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
+
Navigation-shaped updates don't need an action. A plain setter call is enough — reads pull the async, downstream async computeds hold their previous values until new ones are ready, and `isPending`/`latest` expose the in-flight state. Reach for `action` when writes happen *after* async work (pairing with optimistic primitives for tentative state that reverts on failure), not when the async is merely downstream of a synchronous write.
|
|
124
|
+
|
|
125
|
+
Framework-level actions (router form actions, server actions) are specializations of this primitive: the same transactional semantics with form binding, serialization, and submission tracking layered on top.
|
|
126
|
+
|
|
123
127
|
## Optimistic Updates
|
|
124
128
|
|
|
125
129
|
Optimistic signals show an immediate value while async work is pending, then automatically revert when it settles:
|
|
@@ -183,7 +187,7 @@ import { createErrorBoundary, createLoadingBoundary } from "@solidjs/signals";
|
|
|
183
187
|
|
|
184
188
|
createErrorBoundary(
|
|
185
189
|
() => riskyComputation(),
|
|
186
|
-
(error, reset) => handleError(error)
|
|
190
|
+
(error, reset) => handleError(error())
|
|
187
191
|
);
|
|
188
192
|
|
|
189
193
|
createLoadingBoundary(
|
|
@@ -223,10 +227,10 @@ createRoot(dispose => {
|
|
|
223
227
|
| ------------------------ | ------------------------------------------------------------------ |
|
|
224
228
|
| `flush()` | Process all pending updates |
|
|
225
229
|
| `untrack(fn)` | Run `fn` without tracking dependencies |
|
|
226
|
-
| `isPending(accessor)` | Check if an
|
|
227
|
-
| `latest(accessor)` | Get the last resolved value
|
|
228
|
-
| `refresh(accessor)` | Re-trigger an async computation
|
|
229
|
-
| `
|
|
230
|
+
| `isPending(accessor)` | Check if an unrevealed value change is in flight for a read |
|
|
231
|
+
| `latest(accessor)` | Get the last resolved value, or follow not-ready if none exists |
|
|
232
|
+
| `refresh(accessor)` | Re-trigger an async computation (a quiet re-ask — not pending) |
|
|
233
|
+
| `affects(target, key?)` | Declare that in-flight work will change the targeted data (reads pending until settle) |
|
|
230
234
|
| `resolve(fn)` | Returns a promise that resolves when a reactive expression settles |
|
|
231
235
|
| `mapArray(list, mapFn)` | Reactive array mapping with keyed reconciliation |
|
|
232
236
|
| `repeat(count, mapFn)` | Reactive repeat based on a reactive count |
|