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.

UntilDestroy seems to be statefull

See original GitHub issue

In our application we are using local subscriptions to move from one url to another. For our use-case it´s fine. Now we have defined this in our goal component (StartComponent -> GoalComponent):

this.service.localData$
      .pipe(untilDestroyed(this))
      .subscribe((data: any[]) => {
        if (data?.length > 0) {
          this.createTable();
        } else {
          this.goBack();
        }
      });

This gets called in the ngOnInit of the GoalComponent. So in the first case everything works fine. Now when the user navigates back through browser navigation (GoalComponent --> StartComponent) and then moves foreward again (StartComponent -> GoalComponent) with selecting an empty array. The StartComponent refuses to navigate to the GoalComponent:

    if (moreThanOneSelected) {
      this.goTo('goal');
    } else {
      this.alert('Some Text');
    }

So there shouldn´t be any kind of navigation. But here comes the problem. The subscription of localData$ in the GoalComponent is still active and fires the goBack method. I compared it with the classic takeUntil() approach and this one works. So the untilDestroyed is not ending the subscription when the component gets destroyed.

We use:

  • Angular 10
  • Ivy
  • the simplest approach mentioned here with @UntilDestroy() and as pipe operator untilDestroyed(this)

Do you need some more information?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

2reactions
arturovtcommented, Sep 13, 2020

You have to create a minimal project, push it to GitHub and paste a link here. Everyone who sees that issue will be able to debug your example and probably provide a fix.

0reactions
arturovtcommented, Oct 7, 2020

Closing that issue as not reproducible, there seems to be no activity since it’s opened and the reproduction is not provided yet. Feel free to re-open this issue with reproducible example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngneat/until-destroy: RxJS operator that unsubscribe ... - GitHub
RxJS operator that unsubscribe from observables on destroy - GitHub - ngneat/until-destroy: RxJS operator that unsubscribe from observables on destroy.
Read more >
rxjs - Angular 9 observable unsubscribe using @ngneat/until ...
I am using @ngneat/until-destroy this npm package to auto unsubscribe observables. I have used checkProperties: true to auto unsubscribe ...
Read more >
No Description — All Issues - OMG Issue Tracker
Key Issue Reported Fixed Dis... CORBA23‑228 TypeCode constants for bounded strings? CORBA 2.2 CORBA 2.3.1 Res... CORBA23‑227 DynValue::get_members/set_members CORBA 2.2 CORBA 2.3.1 Res... CORBA24‑198 IDL constant...
Read more >
cannot read properties of undefined (reading 'map') angular
HigherIncreases the frequency the app appears ... This first quick fix might be enough for your use case: just default your stateful variable...
Read more >
US7093004B2 - Using execution statistics to select tasks for ...
(If the Task does not appear on either list, it is a redundant Task that has already ... The set will remain on...
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