Is actually possible to do something like this?
import {Injectable} from '@angular/core';
@Injectable()
export class UbiSharedService {
private _ubiData: object = {};
private $$instance: UbiSharedService;
constructor() {
}
public setData(key: string, data: any) {
this._ubiData[key] = data;
}
public getData(key: string): any {
return this._ubiData[key];
}
public popData(key: string): any {
return delete this._ubiData[key];
}
public getInstance(): UbiSharedService {
if (!!this.$$instance && this.$$instance instanceof UbiSharedService) {
//NOOP
}
else {
this.$$instance = new UbiSharedService();
}
return this.$$instance;
}
}