Skip to content

Replace ChildComponent with DestroyRef + takeUntilDestroyed - #608

Merged
dcaslin merged 2 commits into
masterfrom
dcaslin/destroy-ref
Apr 5, 2026
Merged

Replace ChildComponent with DestroyRef + takeUntilDestroyed#608
dcaslin merged 2 commits into
masterfrom
dcaslin/destroy-ref

Conversation

@dcaslin

@dcaslin dcaslin commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Extract shared state into AppStateServiceprovidedIn: 'root' singleton that subscribes to StorageService.settingFeed once, exposing debugmode, disableAds, favoritesList$, favoritesMap, hiddenMilestones, hiddenClanMilestones
  • Rewrite ChildComponent to use inject() field initializers (no constructor params), delegate shared state to AppStateService, and expose destroyRef instead of unsubscribe$
  • Replace takeUntil(this.unsubscribe$) with takeUntilDestroyed(this.destroyRef) across 40+ components, 7 root services (removed entirely — singletons never destroy), and app.component.ts
  • Delete StreamingChildComponent (zero consumers — functionality moved to StreamingService)

88 files changed, 343 insertions, 572 deletions. Templates unchanged — all property names remain identical on component instances.

Test plan

  • ng build — clean compilation
  • npm run test:ci — 185 tests pass
  • npm run lint — 0 errors (465 pre-existing no-explicit-any warnings)
  • Manual smoke test: home page, gear, friends, clan milestones, settings (debugmode toggle)
  • Verify debugmode|async, loading|async, hiddenMilestones|async template bindings work correctly

🤖 Generated with Claude Code

dcaslin and others added 2 commits April 4, 2026 22:35
Extract shared reactive state (debugmode, disableAds, favorites,
hiddenMilestones) into AppStateService. ChildComponent now uses
inject() with no constructor params and delegates to AppStateService.

- Create AppStateService (providedIn: 'root') for shared state
- Rewrite ChildComponent: inject() for DI, expose destroyRef
- Update 76 subclass constructors: remove storageService param
- Replace takeUntil(this.unsubscribe$) with takeUntilDestroyed in 40+ components
- Remove unsubscribe$ from 7 root services (singletons never destroy)
- Delete unused StreamingChildComponent (zero consumers)
- Update app.component.ts with its own DestroyRef

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dcaslin
dcaslin merged commit 930a319 into master Apr 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant