I am using an Event EventEmitter in a service component like this:
export class SettingsService {
public sidebarColor = '#D80B0B';
public sidebarColorUpdate: EventEmitter<string> = new >EventEmitter();
I then subscribe to it from other components like this :
this.settingsService.sidebarColorUpdate.subscribe((color: string) => {
if (color === '#fff') {
this.normalFontColor = 'rgba(0,0,0,.6)';
this.dividerBgColor = 'rgba(0,0,0,.1)';
} else {
this.normalFontColor = 'rgba(255,255,255,.8)';
this.dividerBgColor = 'rgba(255, 255, 255, 0.5)';
}
});
And then unsubscribe in the ngOnDestroy
. This works great but the problem now arises when the session times out and the router defaults back to the login page. After login in again I get this error
message: "object unsubscribed" name: "ObjectUnsubscribedError"
Why is this happening ?