Skip to content

[GSSoC] Computed selectors don't clean up store subscriptions on destroy #1908

Description

@madhuri-perumalla

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.

Metadata

Metadata

Labels

assignedIssue claimed by a contributor.gssoc-requestGSSoC contributor introduction issue.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions