[LayerNext 2] Define attachment scopes and permanent layer disposal

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

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
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Start by reviewing graph.detachLayer(), React effect cleanup for both supported layer models, and the minimap's injected-style pattern. Trace attachment lifecycle handling across the graph, component construction, ports, subscriptions, and scheduled work before settling the public hook and cleanup-registration API. Done means attach/detach/reattach/disposal behavior is defined, all listed resources are released exactly once, StrictMode cleanup is leak-free, migration docs are updated, and existing consumer, strict, and CI checks pass.

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

Mô tả

Parent: #373. Status: deferred. Target branch: v2.

Dependency: #374.

Problem

The current graph.detachLayer() unregisters a layer and removes its DOM, but does not call the component's final unmount. React useLayer invokes this path on effect cleanup. The author-facing afterInit hook runs on every attachment, requires remembering base-hook calls, and cleanup of arbitrary DOM/style resources and scheduled work is easy to miss.

Scope

  • Give LayerNext explicit attach, reversible detach/reattach and permanent disposal semantics.
  • Invoke author hooks after derived construction is complete; do not call overridable initialization hooks from the base constructor.
  • Supply an attached hook context with a guaranteed root and valid declared resources. The engine manages its internal setup without requiring user super calls.
  • Allow attachment hooks to return/register cleanup for graph/DOM/signal subscriptions, temporary elements/styles and scheduled work. Run attach-scoped cleanup before reattachment and final disposal.
  • Add an explicit full-removal operation such as graph.removeLayer(layer): unregister, detach and dispose the component tree and instance-lifetime resources once. Retain a distinct temporary detach path.
  • Use full removal in React effect cleanup for both supported models, including StrictMode and rapid graph/layer replacement.

Acceptance criteria

  • Creation before graph attachment, attach/detach/reattach, repeated detach and repeated disposal have defined behavior.
  • Permanent removal releases children, ports, subscriptions, custom cleanup and scheduled tasks; a disposed instance cannot be reattached silently.
  • Reattachment installs listeners once and leaves no abandoned style elements or other attach-scoped DOM. Cover the minimap's current injected style pattern.
  • Explicit hide/show remains distinct from scale activation; resource and root readiness are accurate.
  • React cleanup and StrictMode do not leave registered layers or live resources behind.
  • Author lifecycle hooks require no super calls and never observe uninitialized derived fields.
  • Migration docs distinguish temporary detach, permanent removal and custom cleanup; existing strict/consumer/CI checks stay green.

Exact public hook names and cleanup registration syntax should be reviewed before implementation. This issue records intended semantics rather than locking an unfinished API.

Ngôn ngữ chính
TypeScript
Star
145
Fork
12
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
43

Chuẩn bị môi trường

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 gravity-ui/graph

Tất cả issue của gravity-ui/graph

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.