-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TakeUntilDestroy not working as expected #4818
Comments
Hi @sebitsi, Thank you. Yes, apparently, it doesn't work anymore. We learned that Ivy collects lifecycle hook methods before initialization and does not call the method on the component instance. Therefore, modifying/patching of In case of absolute need, you may use this library. It has a decorator which patches the component constructor before an instance is created. However, be warned: Custom decorators are by default not tree-shakable. We have not tested this common knowledge against the library though. We will clear all uses of |
No problem. I like to help if i can.
What exactly this mean ? Can you share you approach ? Thanks... |
On components and directives, we will most probably use a service for subscriptions provided and injected at directive-level. On services, depending on the case, |
Is service you mentioned already exists ? |
It soon will. 🙂 |
@armanozak Great work ! I took a peek into documentation file. I like idea how you solved this problem. On the other hand i don't like method names. For example:
Technically this method return subscription and from this point of view name "subcribe" is ok. So, for me, method names like: register, unRegister, attach, detach, etc. are more descriptive. Of course this is my personal opinion. And as i said i took only a peek. :) Regards, |
Hi @sebitsi, I think you took an early peek, because we felt exactly and changed those names before the PR was merged. 🙂 Well, we did not use I hope this works for you, too. I wish you a cheerful day. |
Of course this changes work for me to. Regards. |
I have noticed that TakeUntilDestroy is not unsubscribe from observable.
Simple example:
I have created observable from ngxs state and local variable that stores state into it
Than in OnInit hook i subscribe on this observable like this:
Nothing special really.
All this code is in component managed by router (router-outlet).
When i navigate to another route and than back takeUntilDestroy should unsubscribe from view$.
But it is not.
If i repeate navigate to another route and than back for 4 times and than produce state change i got 4 messages
There should be ony one message !
Is there any limitations using takeUntilDestroy or i'm missing something ?
The text was updated successfully, but these errors were encountered: