How to inject a service in an exported function?

Viewed 3236

I wrote a 'popping' message (android toast like) component. All other components have it as a sibling and access it via a shared service. Now I would like to use it from an utility function too, like this one:

export function handleError(errorResp: Response | any): Observable<string> {
    ....
    // here I would like to display the message
    return Observable.throw(errMsg);
}

I thought I could pass the message service as parameter to handleError, but I feel it's not DRY, as I would need to make it from every component event though the component doesn't need it for other purposes. Could you give me some guidance?

1 Answers
Related