ngneat / reactive-forms

(Angular Reactive) Forms with Benefits 😉
https://www.netbasal.com
611 stars 56 forks source link

Dealing with subscriptions from disabledWhile() #141

Closed undsoft closed 2 years ago

undsoft commented 2 years ago

Description

I've recently discovered that disabledWhile() returns back a Subscription. I'm assuming it is expected that I will be the one unsubscribing in ngOnDestroy.

  1. Isn't there a way to have reactive-forms take care of this subscription without me doing anything?
  2. If not, the need to unsubscribe should probably be highlighted in the docs.
  3. We use until-destroy and having to store subscriptions and unsubscribe will make the code less pretty. Any guidance on better way to do this?

Thanks.

Proposed solution

Have reactive-forms unsubscribe from disabledWhile() Subscription automatically. Or update docs.

Alternatives considered

-

Do you want to create a pull request?

No

NetanelBasal commented 2 years ago

We can't do it automatically because the class isn't aware of life cycle hooks. When you subscribe to something, you have to unsubscribe unless you're explicitly told in the docs that it will happen automatically.