subscription cleanup
Release listeners and subscriptions when their owner stops using them.
Use this when Opening a screen repeatedly causes duplicate events or growing memory.
without the term
“Every time I open and close this screen, the scroll handler fires one more time, and memory keeps going up. Can you make sure stuff gets removed when the screen closes?”
with the term · How do you ask a model for subscription cleanup?
Add subscription cleanup to this component. Mount and unmount it repeatedly and verify that each event invokes one active handler.
What is subscription cleanup?
A subscription has a lifetime. Cleanup detaches it when its owning component unmounts or its inputs change.
Why does subscription cleanup matter when vibe coding?
Generated setup code can work on first mount while leaking on every later mount.
How do you do subscription cleanup?
Pair each registration with cleanup using the same identity. Check repeated mount and unmount cycles.
What goes wrong with subscription cleanup?
Removing a newly created callback leaves the original listener registered.