Is an object provision meant to couple its fields? A part's write to its own state waits for the app's action when the provision also reads a prop the action holds
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 32/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- backend-api-design, developer-experience
Hướng nghiên cứu
Start with the ReactiveScript compiler’s lowering of provide object literals and the hold behavior described in the issue; the payload does not name compiler files or tests. Reproduce the supplied c.rx sequence and compare the listed provision forms, then check the behavior against ref/ as the report notes it was not tested. Done means deciding whether provision fields should couple and documenting or implementing a consistent behavior for the cases raised.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Found while building a component library on ReactiveScript. Written with Claude Fable 5.2 (in Claude Code), which also ran the reproductions; all of them were rerun before posting.
@reactivescript/compiler 0.3.1 through @solidjs/vite-plugin 3.0.0-next.57 on a Vite dev server, mounted with
const app = createApp({ root }); app.mount(main(app)) from @reactivescript/runtime 0.3.1, in Chromium, on
solid-js 2.0.0-rc.22 and on 2.0.0. A Playwright script clicks the buttons and reads the text of the <p>
elements.
https://github.com/solidjs/reactivescript/issues/20 was closed with:
When a write should land now, for example clearing an input, the guide covers it under "What lands together, and what waits" in
guide/async.md, withonFlush(EF-8).
and asked for "a case where plain Solid and the lowered .rx actually behave differently". This is a case onFlush
does not reach, in a component library whose root part provides its state to the other parts, and the Solid
comparison is at the end.
api.js:
export const wait = (ms, value) => new Promise((resolve) => setTimeout(() => resolve(value), ms));
c.rx:
import { wait } from "./api.js"
context menu: { open: boolean; disabled: boolean }
component Popup() {
<p>open: {(use menu).open ? "yes" : "no"}</p>
}
component Menu(props: { disabled: boolean }) {
source open := false
provide menu = { open: open, disabled: props.disabled }
<div>
<button onClick={() => { open := !open }}>toggle</button>
<Popup />
</div>
}
export default component App() {
source step := 1
action next() {
step := 2
try { await wait(300, 0) } catch (e) { }
}
<div>
<button onClick={() => { next() }}>next</button>
<p>step: {step}</p>
<Menu disabled={step == 2} />
</div>
}
| step | screen |
|---|---|
| mount | step: 1, open: no |
| click toggle | step: 1, open: yes |
| click toggle | step: 1, open: no |
| click next | step: 1, open: no |
| click toggle | step: 1, open: no |
| 100 ms later | step: 1, open: no |
| the wait resolves | step: 2, open: yes |
The provision is one equation over open and props.disabled, and Popup reads it, so the menu's open := !open
joins the app's hold on step (H-3). Menu and Popup have no await and no action; App does not contain the
provision. In a library they are in different packages. The compiler reports nothing.
Each row is one change to c.rx, then click next, click toggle:
| change | at the toggle click |
|---|---|
In Menu's handler, let o = !open; onFlush(() => { open := o }) |
open: no until the wait resolves |
context menuOpen: boolean and context menuDisabled: boolean, provide menuOpen = open, provide menuDisabled = props.disabled, and Popup reads use menuOpen |
open: yes |
context menu: { open: () => boolean; disabled: () => boolean }, provide menu = { open: () => open, disabled: () => props.disabled }, and Popup reads (use menu).open() |
open: yes |
provide menu = { open: open, disabled: latest props.disabled } |
open: yes. With <p>disabled: {(use menu).disabled ? "yes" : "no"}</p> added to Popup, that paragraph shows disabled: yes from the click on next, beside step: 1 (this addition ran on rc.22 only) |
In App, source step = 1 and guess step := 2 in place of source step := 1 and step := 2 |
step: 2 at the click on next, then open: yes at the toggle |
An app avoids the wait by not holding a plain write, which AC-1c allows on purpose: "A write meant to be held — a
transition […] is written in a declared action".
In Solid a context value is usually an object of getters or accessors, and that shape does not couple. The page
below, on solid-js alone with the same clicks, shows open: no at the toggle click as written (one memo over the
object, which is what provide emits) and open: yes with ?getters in the URL:
<!doctype html> <button>next</button><button>toggle</button>
<p></p>
<p></p>
<script type="module">
import { createRoot, createSignal, createMemo, createRenderEffect, action } from "solid-js";
const getters = new URLSearchParams(location.search).has("getters");
const [next, toggle] = document.querySelectorAll("button");
const [stepText, openText] = document.querySelectorAll("p");
createRoot(() => {
const [step, setStep] = createSignal(1);
const [open, setOpen] = createSignal(false);
const disabled = () => step() === 2;
// the context value: an object of getters, or one memo over the whole object (what `provide` emits)
const menu = getters
? () => ({
get open() {
return open();
},
get disabled() {
return disabled();
},
})
: createMemo(() => ({ open: open(), disabled: disabled() }));
const hold = action(function* () {
setStep(2);
yield new Promise((r) => setTimeout(r, 300));
});
next.onclick = () => hold();
toggle.onclick = () => setOpen((o) => !o);
createRenderEffect(step, (v) => {
stepText.textContent = "step: " + v;
});
createRenderEffect(
() => menu().open,
(v) => {
openText.textContent = "open: " + (v ? "yes" : "no");
},
);
});
</script>
The question: is provide name = { … } meant to couple its fields, so that a write to the source behind one waits
for a hold on another? If yes, which row of the table should a component library use?
If no, one way: an object literal on the right of provide lowers each field to a getter, which is the functions
row written by the compiler. CP-6b says the compiler's facts already record "a read of one field of props or a
store"; that is compile-time knowledge, not an existing lowering. The cost, as far as I can see it:
- the provision stops being one value (RG-7b: "makes
ethe context's value"), so a consumer of the whole object
(aneffect (use name), an argument to JS, a spread) needs a rule; - each field is evaluated per reader unless it gets its own memo, which adds nodes;
- the literal form then differs from
x = { a: e1, b: e2 }followed byprovide name = x, against E-2; - which right-hand sides qualify (nested literals, spreads, computed keys, a conditional of two literals) has to
be decided.
Not tested: any of the .rx programs against ref/.
- Ngôn ngữ chính
- TypeScript
- Star
- 127
- Fork
- 7
- Merge trung bình
- 15 giờ 42 phút
- Pull request đã merge (30 ngày)
- 63
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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/reactivescript
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
solidjs/reactivescript#96 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Vite front end keeps serving a failed build after the missing/broken imported module is fixedCó thể đã có người làm @cgaaf đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
solidjs/reactivescript#84 ·
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 76/100
solidjs/reactivescript#77 ·
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 78/100
solidjs/reactivescript#74 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
solidjs/reactivescript#97 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/reactivescript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
GetStream/stream-chat-react#3467 ·
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 72/100
vercel-labs/ui#1139 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10Có thể đã có người làm @goranai đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] IntegerRange.contains counts a non-integer just above max as inside an inclusive rangeĐang mởbot:ai-assisted component:platform-js status:untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
midnightntwrk/platform-js#93 ·
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 66/100