purescript-web/purescript-web-workers

Should `MessagePort`, `MessageEvent` and `Transferrable` be in their own module?

JordanMartinez opened this issue · 6 comments

Transferrable is currently problematic as its a placeholder for a better solution, but I think the other two should be in their own module.

Yes. It seems a good idea.
purescript-web-sockets also uses MessageEvent.

If that's where that type should be defined, then we should depend on that library rather than redefining it here.

Why not, but ports and source are not defined here.

MessageEvent is not defined in the WebSockets spec either. They probably did the same thing we did here: define it locally so one can use it.

If I understood correctly, we can:

create a repository for both MessagePort and MessageEvent since there are mutually dependent.
Put IsSendable in this repo.
Maybe, change web-sockets such that it depends on this repo but reexports the functions of MessageEvent such that we don't introduce a breaking change.
MessageEvent.source returns an opaque type MessageEventSource and there is a function

toMessagePort :: MessageEventSource -> Maybe MessagePort

What do you think?

Per the html spec that includes MessageEvent, I think the code should live in web-html.