Trying to overload this method in TypeScript results in it being recognized as a duplicate method. I would like to successfully overload it, though.
import {Injectable, EventEmitter} from '@angular/core';
@Injectable()
export class NotificationService extends EventEmitter<any>{
/**
*
*/
constructor() {
super(false);
}
public error(message:string ):void{
this.emit({message: message, type: 'error'});
}
public error(message:string, type:string):void {
this.emit({message: message, type: type});
}
public success(message:string):void{
this.emit({message: message, type: 'success'})
}
}
I've attempted some other solutions as well but the issue persists.
import {Injectable, EventEmitter} from '@angular/core';
@Injectable()
export class NotificationService extends EventEmitter<any>{
/**
*
*/
constructor() {
super(false);
}
public error(message:string, type?:string ):void{
this.emit({message: message, type: 'error'});
}
public error(message:string, type:string):void {
this.emit({message: message, type: type});
}
public success(message:string):void{
this.emit({message: message, type: 'success'})
}
}
The goal is to have it emit an HTTP API response code.