nuxt-modules / partytown

Partytown integration for Nuxt. Run third-party scripts from a web worker.
MIT License
319 stars 8 forks source link

Communicate with web worker #156

Closed stephenjason89 closed 1 year ago

stephenjason89 commented 1 year ago

How do we communicate with the web worker like postMessage and stuff

danielroe commented 1 year ago

You can find the docs here: https://partytown.builder.io.

stephenjason89 commented 1 year ago

Thanks @danielroe I might be wrong, but I have a 3 webworker scripts that i register like

image

from the worker itself i can call postMessage to send a message

image

I can then listen to the webworker's message like this

image

Is partytown able to handle this kind of stuff? From the documentation above, I am not so certain.

I am currently using https://www.npmjs.com/package/worker-plugin

Any clarifications on the matter is deeply appreciated.

danielroe commented 1 year ago

It's not like your other web workers in that you don't need to manually post messages. partytown automatically forwards events: https://partytown.builder.io/forwarding-events.

If it's not a Nuxt question, I would recommend engaging on https://github.com/BuilderIO/partytown instead.

stephenjason89 commented 1 year ago

thank u @danielroe