Skip to content

Commit

Permalink
fix: Fixed BaseComponent | release Listening ThemeService
Browse files Browse the repository at this point in the history
  • Loading branch information
DaikiMiyajima committed Feb 10, 2025
1 parent cd5848c commit a85c8d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/primeng/src/basecomponent/basecomponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class BaseComponent {

attrSelector = uuid('pc');

private themeChangeListeners: Function[] = [];

_getHostInstance(instance) {
if (instance) {
return instance ? (this['hostName'] ? (instance['name'] === this['hostName'] ? instance : this._getHostInstance(instance.parentInstance)) : instance.parentInstance) : undefined;
Expand Down Expand Up @@ -81,6 +83,7 @@ export class BaseComponent {

ngOnDestroy() {
this._unloadScopedThemeStyles();
this.themeChangeListeners.forEach((callback) => ThemeService.off('theme:change', callback));
}

_loadStyles() {
Expand Down Expand Up @@ -160,6 +163,7 @@ export class BaseComponent {
_themeChangeListener(callback = () => {}) {
Base.clearLoadedStyleNames();
ThemeService.on('theme:change', callback);
this.themeChangeListeners.push(callback);
}

cx(arg: string, rest?: string): string {
Expand Down

0 comments on commit a85c8d1

Please sign in to comment.