[LayerNext 2] Define attachment scopes and permanent layer disposal

未关闭
#375 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, typescript
领域
frontend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
145
派生
12
平均合并
1 天 14 小时
30 天内合并 PR
43

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

gravity-ui/graph 的其他 Issue

查看 gravity-ui/graph 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。