-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMessagePort.res
More file actions
40 lines (33 loc) · 1.44 KB
/
MessagePort.res
File metadata and controls
40 lines (33 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
open ChannelMessagingAPI
include EventTarget.Impl({type t = messagePort})
/**
Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side.
Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
*/
@send
external postMessage: (messagePort, ~message: JSON.t, ~transfer: array<Dict.t<string>>) => unit =
"postMessage"
/**
Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side.
Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
*/
@send
external postMessageWithOptions: (
messagePort,
~message: JSON.t,
~options: structuredSerializeOptions=?,
) => unit = "postMessage"
/**
Begins dispatching messages received on the port.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
*/
@send
external start: messagePort => unit = "start"
/**
Disconnects the port, so that it is no longer active.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
*/
@send
external close: messagePort => unit = "close"