ngneat / overview

🤖 A collection of tools to make your Angular views more modular, scalable, and maintainable
MIT License
121 stars 7 forks source link

fix: add protection for null comRef #7

Closed gili-lumigo closed 3 years ago

gili-lumigo commented 3 years ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[V] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Because we're using the ngDoCheck hook there are cases that it has been called multiple times. For ex. when a loader component appears more than once upon user event. The comRef is getting cleared at the first time and when it calls it again we're getting an error.

Issue Number: N/A

What is the new behavior?

Added protection in onDestroy to verify there is an instance of comRef before destroying it.

Does this PR introduce a breaking change?

[ ] Yes
[V] No

Other information