-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat(effects-ng): Directive effects #41
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
Conversation
|
That's the implementation. What do you think about it @NetanelBasal? It seems to be a little strange, and unusual, maybe because of the new API. |
Yes, that's exactly what I meant. |
Faced with new and new corner cases. But this implementation should cover everything. |
@EricPoul, I'm trying to understand the use cases you're trying to handle. Let's say I have an effect named Cases:root - TodosEffects - subscribe here root - TodosEffects - subscribe here env injector - TodosEffects - subscribe here root - TodosEffects - subscribe here useDirectiveEffects- TodosEffects - subscribe here What am I missing? |
TodoComponent(instance 1) - useDirectiveEffects - TodosEffects(instance 1) - subscribe here TodoComponent(instance 1).onDestory() - effects of TodosEffects(instance 1) should still be alive Although TodosEffects(instance 1) and TodosEffects(instance 2) has the same names of effects, effects themself are different and have different references. |
but why do we care about references? The suggestion was to unique it based on the constructor name + the effect prop name. TodosEffect/getTodos |
|
And that will stay. We will have a global Set that registers the unique identifiers. Before registering an effect, you will check if it exists in the Set. if that's the case, skip it. |
It's what I do. TodoComponent(instance 1) - useDirectiveEffects - TodosEffects(instance 1) - subscribe here TodoComponent(instance 1) was destroyed - effects of TodosEffects(instance 1) should still be alive because TodoComponent(instance 2) and TodoComponent(instance 3) are still alive. TodoComponent(instance 3) was destroyed - effects of TodosEffects(instance 1) should still be alive because TodoComponent(instance 2) is still alive. TodoComponent(instance 2) was destroyed - effects of TodosEffects(instance 1) should be removed. |
The problem that I described is only with components and their chaotic order of being destroyed. For |
I see, but that's not the purpose of the feature as I see it. It should be only for development and should immediately throw when seeing that you try to use the same effect multiple times. We don't need to manage subscriptions. I think it's a bad design if someone gets to the case you described. |
We help by saying "Hi, you're registering the same effect multiple times. That's not a good thing to do" |
But you're the consumer of the library. If you think we should leave your implementation, let it be. |
Let's leave your code. You already wrote it. I'd just add a test for the exact scenario you describe here |
I really don't know how is better😄 |
useDirectiveEffects should be the same as provideEffects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. We just need to update the docs.
I'll go through the changes once more and update the docs after. Once I do I'll mark this pr as |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information