question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

untilDestroyed(this)) not working on route change

See original GitHub issue

I just trying to unsubscribe on route change but its not working

@UntilDestroy({ checkProperties: true })
@Component({
   .
   .
   .
    changeDetection: ChangeDetectionStrategy.OnPush
})

ngOnInit(): void {
interval(1000)
     .pipe(untilDestroyed(this))
     .subscribe((count) => {
         console.log('count:', count);
     });
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

3reactions
arturovtcommented, Aug 27, 2020

I’ve published @ngneat/until-destroy@8.0.2 with updated readme.

1reaction
digeomelcommented, Aug 25, 2020

@8.0.1 is meant to be used with Angular 10, not 9.

@arturovt I agree with @Smip , this should be added to the readme. We have lots of warnings when doing npm install and these can be easily missed. Just lost an hour+ trying to find out what’s going on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

akita-state-management/Lobby - Gitter
I recently added persistState to main.ts in my app, but unfortunately started seeing issues related to zones and change detection. I'm wondering you...
Read more >
Angular/RxJS When should I unsubscribe from `Subscription`
I tried seangwright's solution (Edit 3). That is not working for Observable that created by timer or interval.
Read more >
[4+1 ways] How to Unsubscribe from Observables in Angular ...
Our code seems to work! BUT, what would happen if we destroy this component (e.g by navigating to an other route that doesn't...
Read more >
@ngneat/until-destroy | Yarn - Package Manager
... @UntilDestroy() @Component({}) export class InboxComponent { ngOnInit() { interval(1000).pipe(untilDestroyed(this)).subscribe(); } }.
Read more >
Auto Unsubscribing From Observables On NgDestroy
A common pattern when working with observables/subjects inside an Angular Component, is to store the subscriptions in a list, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found