Docs: is a store proxy read inside an open setter guaranteed to return the staged value?
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- documentation
Hướng nghiên cứu
Đọc documentation/solid-2.0/04-stores.md, đặc biệt là “Draft-first store setters”, và kiểm tra ghi chú về internals của store liên quan đến backing đang chờ được đề cập trong issue. Xác nhận liệu việc đọc proxy khi setter đang mở có phải là hành vi được chủ định hay không, rồi ghi rõ đảm bảo đó trong hướng dẫn và/hoặc TSDoc của createStore. Hoàn tất khi tài liệu nêu rõ store.x đọc giá trị nào bên trong setter và phân biệt rõ ràng với các giá trị đã được commit.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 37k
- Fork
- 1.2k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[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 handlesCó thể đã có người làm @MilindChatrabhuji đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[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)Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
agents-window vscode api adoption
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
alefragnani/vscode-copy-word#126 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opensro-dev/opensro#4949 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:linux priority:high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
fa0311/better-tokuly#1204 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
saltbo/zpan#883 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement impeccable priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nledford/Ladderback#1891 ·
Maintainer thường phản hồi trong vòng 1 ngày