HttpClient in Worker?


Is it possible to use angular HttpClient in background Workers?


No, I don’t think it is possible. Worker runs on separate thread and your application / angular runs on main thread. You can’t share anything between them other than serializable objects through post message.

Is there any specific reason why you want to do this?


Thanks. I need to move some of my logic to a background worker and I was looking for a way to move what I already have without the need to recreate it by splitting worker and http to different modules or by replacing the angular methods I already have with a NS core http module in the worker.


NativeScript already runs Http calls on separate thread so until you are doing anything heavy for main thread on http success, you really don’t have to move them.


Yes I’m aware of that, however restructuring my code is the problem, moving some parts to the worker, some from their injectabale service to worker-readable format etc. I was looking for a way to just use everything as-is (more or less) instead of reconstructing it.