Gotcha with ReactiveSet/Map iterators
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- frontend
调研方向
从 packages/map/src/index.ts 的第 49-55 行开始,将 ReactiveSet/Map 的迭代器方法与链接的 SvelteSet 和 Map 实现进行比较。使用 StackBlitz 重现来验证,在不消费迭代器的情况下调用 values()、keys() 或 items() 会注册 tracking;当更改按预期触发异步 effect 时即表示完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Using .keys(), .values() or .items() on a ReactiveSet or ReactiveMap is meant to track all keys/values for changes. However, if the iterators are not consumed, then no tracking is registered.
This comes up when trying to declare dependencies of an asynchronous effect beforehand.
createEffect(() => {
// Track set for changes
void set.values();
setTimeout(() => /* Use set contents... */);
});
Though the intention was to track the full content of the set, the above effect is not actually triggered by changes to the set.
The reason this happens is that the methods are implemented as generators like so:
The beginning of the method is not run until .next() is called for the first time.
I think the methods should not be generators themselves, rather just return super.values(). That would probably be more performant as well. SvelteSet & Map are implemented like this.
Happy to to write a PR if there is agreement.
Minimal Reproduction Link
https://stackblitz.com/edit/github-r2lfqdu4?file=src%2FApp.tsx
- 主要语言
- TypeScript
- 星标
- 1.6k
- 派生
- 162
- 平均合并
- 19 小时 40 分钟
- 30 天内合并 PR
- 8
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs-community/solid-primitives 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
solidjs-community/solid-primitives#1059 · 1 条评论 ·
-
bug
难度 3/5 1-2 天 新手友好度 68/100
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
-
bug
难度 3/5 1-2 天 新手友好度 55/100
solidjs-community/solid-primitives#1000 · 3 条评论 · 5 个 reaction ·
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
查看 solidjs-community/solid-primitives 的全部 Issue
相似的 Issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
-
Crush 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
catppuccin/catppuccin#3125 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
ElementsProject/cln-application#167 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Quantco/pnpm-licenses#17 ·
-
难度 2/5 1-3 小时 新手友好度 75/100