Docs: is a store proxy read inside an open setter guaranteed to return the staged value?
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, typescript
- Ambito
- documentation
Direzione di ricerca
Leggi documentation/solid-2.0/04-stores.md, in particolare “Draft-first store setters”, e consulta la nota sugli internals dello store relativa al backing in sospeso menzionato nell’issue. Verifica se le letture del proxy durante un setter aperto sono un comportamento previsto, quindi documenta questa garanzia nella guida e/o nella TSDoc di createStore. Il lavoro è completato quando la documentazione indica chiaramente cosa legge store.x all’interno del setter e la distinzione dai valori confermati è inequivocabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What this is
A documentation request about an existing 2.0 store behaviour, with a script that shows it. We hit it porting a Solid 1 app (kolu) to Solid 2.
Inside an open setter, a read through the store proxy (store.x, not draft.x) returns the value the setter has staged so far, not the last committed one. That is very useful — a helper called from inside the setter only has the store, not the draft — but we could not find it stated anywhere in the docs, so we do not know whether we may rely on it.
Version
[email protected] (latest) and [email protected] (next), Node 24, Linux. Same output on both.
Reproduction
// staged-read.js
import { createRoot, createStore, flush } from "solid-js";
let store, setStore;
createRoot(() => {
[store, setStore] = createStore({ seen: 0, rows: ["a"] });
});
// a helper that only has the store, not the draft
const seenSoFar = () => store.seen;
console.log("outside a setter: store.seen =", store.seen);
setStore((draft) => {
draft.seen = 1;
draft.rows.push("b");
console.log("inside the setter: store.seen =", store.seen);
console.log("inside the setter: store.rows =", JSON.stringify(store.rows));
console.log("inside the setter: draft.seen =", draft.seen);
console.log("inside the setter, via a helper that reads the store:", seenSoFar());
});
flush();
console.log("after the setter: store.seen =", store.seen);
// folding frames: every line reads what the lines before it staged
setStore((draft) => {
for (const n of [2, 3, 4]) {
draft.seen = store.seen + 1;
if (store.seen !== n) throw new Error(`expected ${n}, read ${store.seen}`);
}
});
flush();
console.log("after folding 3 frames: store.seen =", store.seen);
$ npm i [email protected]
$ node --conditions=browser --conditions=development staged-read.js
outside a setter: store.seen = 0
inside the setter: store.seen = 1
inside the setter: store.rows = ["a","b"]
inside the setter: draft.seen = 1
inside the setter, via a helper that reads the store: 1
after the setter: store.seen = 1
after folding 3 frames: store.seen = 4
The ask
Either:
- document it — one or two sentences under "Draft-first store setters" in
documentation/solid-2.0/04-stores.md(and/or increateStore's TSDoc), saying that while a setter is open the proxy serves the setter's staged view, sostore.xinside the callback reads what earlier lines of that callback wrote; or - say it is not a guarantee, in which case we will thread the draft through every helper instead.
Today the only statement we could find is in the store internals (the proxy serving the "pending backing" the draft mutates), which reads as an implementation note rather than a promise to users. 04-stores.md covers the draft-first setter, returning a value for a shallow replace, path-setter migration, class instances and snapshot, but says nothing about reading the store itself while a setter is open.
Why it matters to us
Code that folds incremental frames does the update in one setter and calls small helpers from inside it; those helpers close over the store, not the draft. If the staged view is a guarantee, that shape is correct and pleasant. If it is incidental, every such helper needs the draft threaded in, and we would rather change that now than after it silently starts reading committed values.
This was written by an AI agent (Claude) under a human maintainer's direction.
- Lingua principale
- TypeScript
- Stelle
- 37k
- Fork
- 1.2k
- Merge medio
- 8h 43m
- PR unite (30g)
- 365
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di solidjs/solid
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
I maintainer di solito rispondono entro 1 giorno
-
[2.0.4] Nested `<Errored>`: the outer boundary stays on an error the inner one rethrew, after the next error is one the inner one handlesForse già presa @MilindChatrabhuji l’ha presa 2 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
[2.0.4] A waiting action started from a cleanup holds back an effect's write that reacts to the same landing (follow-up to #5251)Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid
Issue simili
-
agents-window vscode api adoption
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
alefragnani/vscode-copy-word#126 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opensro-dev/opensro#4949 ·
I maintainer di solito rispondono entro 1 giorno
-
agent:linux priority:high
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
fa0311/better-tokuly#1204 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
saltbo/zpan#883 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement impeccable priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nledford/Ladderback#1891 ·
I maintainer di solito rispondono entro 1 giorno