I have a service that is being used for heavy computation in an Angular app. I'm using @injectable with the services' class. I'd like to use the class in a web worker as well, but it's throwing dom related errors. What's the best way to reuse the service code? I could write a plain class but would like to avoid duplicating the code as it's still needed inside the app.
I'd like to do something like this:
// web worker
import {Service} from 'app.service.ts';
addEventListener('message', ({ data }) => {
const response = new Service().callServiceMethod(data);
postMessage(response);
});