Closed shadow puppet cue previews continue receiving notifications
Level 2 · node · Reliability · Callback identity mismatch between subscription registration and disposal
Scenario
A fictional shadow puppet rehearsal studio delivers scene cues through an in-memory event bus. Each preview panel displays only cues for its selected track. Open panels show the correct content, but closed or reopened panels leave earlier panels receiving cues. Review the panel lifecycle together with the registration and removal contract of the event bus.
Requirements
createStudio() exposes open(track, render), emit(track, label), and activeCount(). open creates an independent subscription that passes label to render for each cue on the selected track and returns a disposal function. After disposal that subscription receives no more cues, while other subscriptions using the same render remain active. Repeated disposal calls must be safe. activeCount returns the actual number of registered listeners. The bus manages registered function references directly and depends on no external services or timers.
Acceptance criteria
- Open panels receive only cues for their own tracks in registration order.
- Closed panels receive no subsequent cues and the actual listener count decreases.
- Closing one independent subscription that shares a renderer leaves the remaining subscription functional.
- Repeated opening, closing and disposal calls leave no lingering listeners.