Stop closed editor tabs from receiving document updates
Opening and closing the preview panel twenty times makes one edit trigger twenty-one outline refreshes. Subscriptions remain in the document store after the panel unmounts.
- Focused work estimate
- 2h 30m + prerequisites
- Priority in the scenario
- Medium
- Engineering practice
- Resource lifecycle · Observer delivery · Failure isolation
Estimated field mix
- Frontend60%
- Performance engineering40%
Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.
Pattern topics
- ObserverRefactor
Repair subscription ownership and notification semantics so repeated panel mounts do not retain listeners or multiply document update work.
Review it, then add it to your workspace.
The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.
Project context
A fictional support team edits reusable troubleshooting documents with paragraphs, links, and nested sections. The browser prototype has separate toolbar and keyboard handlers, an unreliable undo stack, and mutable shared formatting objects. Create a local editor and synthetic documents; no starter assets, rich-text engine, collaborative backend, or production service is supplied.
Setup prerequisites
- Browser events
- Immutable updates
- Accessible form controls
Preceding work
Complete these dependencies, or supply their agreed outputs before taking this ticket.
Acceptance criteria
- Each subscription has an idempotent unsubscribe operation tied to the subscribing component's lifetime.
- One committed document operation sends one versioned notification to each active subscriber, including when callbacks subscribe or unsubscribe during delivery.
- A failed subscriber does not stop delivery to other subscribers, and errors are reported without logging document content.
Implementation constraints
- Keep the Observer surface small and define whether delivery is synchronous; avoid a global application event bus for this document-local need.
Verification to include
- Mount and unmount the preview twenty times, edit once, and assert only active listeners run.
- Have one listener throw and another unsubscribe during delivery; verify remaining delivery and the next notification set.
Deliverables
- Subscription lifecycle fix and repeated-mount regression
Rollout and recovery
Replace document-local subscriptions together; reset transient listeners on reload without changing saved document data.
Value of the work
For the engineer: Practice relating object and state patterns to real UI behavior, including undo semantics, bounded traversal, lifecycle cleanup, and memory tradeoffs.
For the team: Review whether editor changes preserve user work, keep controls consistent, and reduce maintenance effort without concealing document corruption.
Evidence boundaries
Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.
Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.