ngneat / until-destroy

🦊 RxJS operator that unsubscribe from observables on destroy
https://netbasal.com/
MIT License
1.74k stars 100 forks source link

untilDestroyed assumes ngDevMode is defined #221

Closed Patrick-Clausen closed 1 year ago

Patrick-Clausen commented 1 year ago

The untilDestroyed function seems to use the global variable ngDevMode to specify whether it should add a bit of extra debug information.

The implementation of this assumes that ngDevMode is defined, and is either truthy or falsy. However, according to Angular's implementation, it can actually be truthy, falsy or undefined: https://github.com/angular/angular/blob/main/packages/core/src/util/ng_dev_mode.ts#L24

In some specific setups of Angular applications, this means that any component using the untilDestroyed method can't be instantiated.

Suggest doing a more resilient check, like Angular do themselves: https://github.com/angular/angular/blob/main/packages/core/src/util/ng_dev_mode.ts#L118

Or simply relying on angular's own isDevMode() method, which does the same thing.

arturovt commented 1 year ago

Fixed in 9.2.3.

Patrick-Clausen commented 1 year ago

Impressive turn-around, thanks a lot!