Skip to content

Migrate subscription cleanup to takeUntilDestroyed #551

@bracyw

Description

@bracyw

Description

Components across the codebase manage observable subscriptions manually with Subscription[] arrays and ngOnDestroy cleanup. Angular 16+ provides takeUntilDestroyed() from @angular/core/rxjs-interop which automatically unsubscribes when a component is destroyed — no OnDestroy boilerplate needed. This ticket migrates all components to that pattern, which also fixes ~18 components that currently have no cleanup at all.

Acceptance Criteria

  • All components using manual Subscription[] + ngOnDestroy cleanup are migrated to takeUntilDestroyed()
  • All components that currently lack cleanup (~18) are fixed by adding takeUntilDestroyed() to their subscribe pipes
  • Remove OnDestroy implementations that only exist for subscription cleanup
  • No behavioral changes — only lifecycle cleanup approach changes
  • Run ng build to verify no regressions

Proposed Solution

Import DestroyRef and takeUntilDestroyed from @angular/core/rxjs-interop. Inject DestroyRef, then pipe each observable through takeUntilDestroyed() before subscribing. Remove the Subscription[] array, the push calls, and the ngOnDestroy forEach unsubscribe block. Start with the ~18 components missing cleanup entirely, then migrate the ~25 components that already have manual cleanup. Test with ng build.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions