zefoy / ngx-color-picker

Color picker widget for the Angular (version 2 and newer)
MIT License
457 stars 143 forks source link

ColorPickerService should be providedIn: 'root' #326

Open jnizet opened 1 year ago

jnizet commented 1 year ago

The only state of the service is the active color picker:

  private active: ColorPickerComponent | null = null;

  public setActive(active: ColorPickerComponent | null): void {
    if (this.active && this.active !== active && this.active.cpDialogDisplay !== 'inline') {
      this.active.closeDialog();
    }

    this.active = active;
  }

The intention of this code, as I understand it, is to have only one active color picker at once in the application. It doesn't make much sense to me to have one active color picker per lazy-loaded module. And if that was really desired, it would still be possible to explicitly add the service to the providers of each module.