Add DEV.setSignal so devtools can write a signal or store node
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- devtools
调研方向
Start from the DEV object that already exposes getSignals, getSources and getObservers, and from the write path behind the setter createSignal returns. Store slot nodes (those with _host and _key) must go through the store setter so onStoreNodeUpdate and subscribers fire. Done means DEV.setSignal works in dev builds for both node kinds, honours equals and scheduling, and can be called from outside an owned scope.
由索引模型根据 Issue 内容生成。
描述
Devtools can read a signal through DEV, but cannot write one. I'd like a dev-only hook that sets a signal node, or the slot node of a store property, to a new value and notifies its subscribers.
DEV.setSignal(node: Signal<any>, value: unknown): void
Why
The state editor in solidjs/solid-start-devtools#41 lets a developer change a signal or store value from the devtools panel and see the app update. The panel gets nodes from DEV.getSignals and DEV.getSources. It does not have the setter the app got from createSignal or createStore, and writing node._value changes the value without notifying anyone.
To get around this, the PR creates its own createSignal(0) and redefines about 20 fields on that node (_value, _subs, _subsTail, _pendingValue, _statusFlags, _equals, _time, _notifiedAt, _owner, _transition, _firewall and others) as getters and setters that forward to the target node. It then calls its own setter, so the runtime's write path runs against the target. For a store slot it also writes _host.v[_key] and _host.pb[_key] directly.
This works on 2.0.0-rc.20, but it depends on private field names. A rename or a new field in a release breaks editing without a type error. The DEV object already has getSignals, getSources and getObservers, so the runtime is the place that can keep a write hook working.
Proposed behavior
- For a signal node: same as calling the setter
createSignalreturned, includingequals, notification and scheduling. - For a store property slot node (a node with
_hostand_key): same as writing that property through the store setter, soonStoreNodeUpdateand the store's subscribers see it. - Only in dev builds, like the rest of
DEV. - Callable outside an owned scope, from a devtools UI event. The devtools call it inside
runWithOwner(null, …)today to avoidREACTIVE_WRITE_IN_OWNED_SCOPE.
Nested paths are not needed. The devtools build the new value for the node from a path itself, and only write plain objects and arrays.
Devtools side
solidjs/solid-start-devtools#41 already calls DEV.setSignal when it is a function and falls back to the bridge otherwise, so the bridge can be removed once a release has the hook.
- 主要语言
- TypeScript
- 星标
- 36.2k
- 派生
- 1.1k
- 平均合并
- 9 小时 56 分钟
- 30 天内合并 PR
- 487
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 22/100
维护者通常 1 天内回复
-
What gets passed to the `when` prop of a `Show` still gets executed twice on SSR可能已有人在做 @brenelz 于 5 天前认领。 未关闭1.x
难度 3/5 1-2 天 新手友好度 52/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
Open-Earth-Foundation/CityCatalyst#3399 ·
维护者通常 2 天内回复
-
userReport
难度 1/5 1 小时以内 新手友好度 72/100
nkprasad12/morcus-net#631 ·
维护者通常 1 天内回复
-
fix(app): fail closed if GetGeneralSetting fails during initialization可能已有人在做 @kalavt 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
nekko-labs/nekko-agent#1756 ·
维护者通常 1 天内回复
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复