-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessagePort.cljs
102 lines (73 loc) · 3.09 KB
/
MessagePort.cljs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
(ns web.other.MessagePort
"The MessagePort interface of the Channel Messaging API represents
of the two ports of a `web.other.MessageChannel`, allowing messages
be sent from one port and listening out for them arriving at
other."
(:refer-clojure :exclude []))
(defn post-message
"Method.
The postMessage() method of the `web.other.MessagePort` interface
a message from the port, and optionally, transfers ownership
objects to other browsing contexts.
`port.postMessage(message, transferList);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage`"
[this message transfer-list]
(-> this (.postMessage message transfer-list)))
(defn start
"Method.
The start() method of the `web.other.MessagePort` interface starts
sending of messages queued on the port. This method is only needed
using `EventTarget.addEventListener`; it is implied when using
`port.start()`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/start`"
[this ]
(-> this (.start)))
(defn close
"Method.
The close() method of the `web.other.MessagePort` interface disconnects
port, so it is no longer active. This stops the flow of messages
that port.
`port.close()`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/close`"
[this ]
(-> this (.close)))
(defn onmessage
"Property.
The onmessage event handler of the `web.other.MessagePort` interface
an `web.EventListener`, called whenever an `web.workers.MessageEvent`
type message is fired on the port — that is, when the port receives
message.
`channel.onmessage = function() { ... };`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage`"
[this]
(-> this (.-onmessage)))
(defn set-onmessage!
"Property.
The onmessage event handler of the `web.other.MessagePort` interface
an `web.EventListener`, called whenever an `web.workers.MessageEvent`
type message is fired on the port — that is, when the port receives
message.
`channel.onmessage = function() { ... };`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage`"
[this val]
(aset this "onmessage" val))
(defn onmessageerror
"Property.
The onmessageerror event handler of the `web.other.MessagePort`
is an `web.EventListener`, called whenever an `web.workers.MessageEvent`
type messageerror is fired on the port—that is, when it receives
message that cannot be deserialized.
`port.onmessageerror = function() { ... };`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessageerror`"
[this]
(-> this (.-onmessageerror)))
(defn set-onmessageerror!
"Property.
The onmessageerror event handler of the `web.other.MessagePort`
is an `web.EventListener`, called whenever an `web.workers.MessageEvent`
type messageerror is fired on the port—that is, when it receives
message that cannot be deserialized.
`port.onmessageerror = function() { ... };`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessageerror`"
[this val]
(aset this "onmessageerror" val))