Great article that helped me a lot! one question though, how would you make a message back to the main thread? I have been trying to do MyWorker.onmessage but it gives me an error. Return would not be suitable for my app.
Hi Vicente! Thank you!
Do you want to receive a value from your service worker in you main thread? I think comlink hides the onmessage thing so you can return a value from a method in the web worker. Take a look at this example 🙂
Just remember, methods in web worker will always return a promise.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article that helped me a lot! one question though, how would you make a message back to the main thread? I have been trying to do MyWorker.onmessage but it gives me an error. Return would not be suitable for my app.
Thanks!
Hi Vicente! Thank you!
Do you want to receive a value from your service worker in you main thread? I think comlink hides the onmessage thing so you can return a value from a method in the web worker. Take a look at this example 🙂
Just remember, methods in web worker will always return a promise.