A new GameService
has been crafted with the implementation of the ServiceInterface
:
export interface ServiceInterface {
emitter$;
actions: any[];
[action: string]: any;
}
export class GameService implements ServiceInterface {
constructor() {
super();
this.actions = [
{ name: 'createGame$', handler: this.createGame.bind(this) }
];
this.initializeActions();
}
initializeActions() {
// creating action subject and subscribing handlers for each action
if (this.actions) {
for (let action of this.actions) {
this[action.name] = new Subject();
this[action.name].subscribe(action.handler);
}
}
}
The issue arises when trying to add properties dynamically in the GameService
, like this.createGame$
. An error message pops up:
Property 'createGame$' does not exist on 'GameService'
It was assumed that using [action: string]: any;
within the interface would enable dynamic property addition - what could possibly be missing?