Summary
The computed() method creates an internal subscription to the store but does not retain the unsubscribe callback returned by subscribe(). Although the store exposes a destroy() method, these internal subscriptions are not explicitly cleaned up during destruction.
As a result, subscriptions may remain active after the store is destroyed, potentially leading to lingering references when stores are repeatedly created and destroyed.
Expected Behavior
The store should internally track unsubscribe callbacks created by computed selectors and invoke them during destroy(), ensuring all internal subscriptions are properly cleaned up.
Impact
- Prevents lingering subscriptions after store destruction.
- Improves lifecycle consistency for computed selectors.
- Helps avoid unnecessary memory retention in applications that dynamically create and destroy stores.
Package
@termuijs/store
Additional Context
- The store already provides a
destroy() lifecycle.
subscribe() already returns an unsubscribe function.
- The fix can be implemented internally without changing the public
Computed API.
Summary
The
computed()method creates an internal subscription to the store but does not retain the unsubscribe callback returned bysubscribe(). Although the store exposes adestroy()method, these internal subscriptions are not explicitly cleaned up during destruction.As a result, subscriptions may remain active after the store is destroyed, potentially leading to lingering references when stores are repeatedly created and destroyed.
Expected Behavior
The store should internally track unsubscribe callbacks created by computed selectors and invoke them during
destroy(), ensuring all internal subscriptions are properly cleaned up.Impact
Package
@termuijs/storeAdditional Context
destroy()lifecycle.subscribe()already returns an unsubscribe function.ComputedAPI.