After creating a 'popping' message component similar to Android toast, I have integrated it as a sibling in all other components through a shared service. Now, I want to utilize this component within a utility function like the following:
export function handleError(errorResp: Response | any): Observable<string> {
....
// display the message here
return Observable.throw(errMsg);
}
My initial thought was to pass the message service as a parameter to handleError function. However, I am concerned about redundancy, as I would have to include it in every component even if not required for other purposes. Can you offer some advice on how to approach this situation?