Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Gotcha with ReactiveSet/Map iterators

Đang mở
#830 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu tại packages/map/src/index.ts, các dòng 49-55, và so sánh các phương thức iterator của ReactiveSet/Map với các triển khai SvelteSet và Map được liên kết. Sử dụng bản tái hiện trên StackBlitz để xác minh rằng việc gọi values(), keys() hoặc items() mà không tiêu thụ iterator sẽ đăng ký tracking; hoàn tất khi các thay đổi kích hoạt hiệu ứng bất đồng bộ như dự kiến.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

help wanted
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:

https://github.com/solidjs-community/solid-primitives/blob/507ff661656cd51e3c280d0776054f487f0507de/packages/map/src/index.ts#L49-L55

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

Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
162
Merge trung bình
19 giờ 40 phút
Pull request đã merge (30 ngày)
8

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của solidjs-community/solid-primitives

Tất cả issue của solidjs-community/solid-primitives

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.