Мне нужно унаследовать синглтон-класс и переопределить его метод.это возможно в машинописи?или любой другой способ реализовать этот тип сценария в машинописи.
// Родительский класс
export class SFSCommands {
static instance: SFSCommands;
protected constructor() {
if (SFSCommands.instance) {
return SFSCommands.instance;
}
setInterval(() => {
this.initSfsCommands('sss');
}, 2000);
}
static getInstance() {
if (!SFSCommands.instance) {
SFSCommands.instance = new SFSCommands();
}
return SFSCommands.instance;
}
initSfsCommands(e: any) {
console.log('comming in service');
}
}
// **** Детский класс ***********
import { SFSCommands } from '../utility/sfscommands';
export abstract class GameModel extends SFSCommands {
roomName: string;
constructor() {
super();
console.log(this);
}
// called from child whien game component inisilized
initSfsCommands(event: any) {
console.log('game model');
}
}
Я звоню SFSCommands.getInstance () из моего app.component.ts file