/
BroadcastChannel.cljs
114 lines (82 loc) · 3.86 KB
/
BroadcastChannel.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
102
103
104
105
106
107
108
109
110
111
112
113
(ns web.broadcast.BroadcastChannel
"The BroadcastChannel interface represents a named channel that
browsing context of a given origin can subscribe to. It allows
between different documents (in different windows, tabs, frames
iframes) of the same origin. Messages are broadcasted via a message
fired at all BroadcastChannel objects listening to the channel."
(:refer-clojure :exclude [name]))
(def constructor
"Constructor.
The BroadcastChannel() constructor creates a new `web.broadcast.BroadcastChannel` and connects it to the underlying channel.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/BroadcastChannel`"
js/BroadcastChannel)
(defn post-message
"Method.
The BroadcastChannel.postMessage() sends a message, which can
of any kind of `js.Object`, to each listener in any browsing
with the same origin. The message is transmitted as a message
targeted at each BroadcastChannel bound to the channel.
`var str = channel.postMessage(object);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/postMessage`"
[this object]
(-> this (.postMessage object)))
(defn close
"Method.
The BroadcastChannel.close() terminates the connection to the
channel, allowing the object to be garbage collected. This is
necessary step to perform as there is no other way for a browser
know that this channel is not needed anymore.
`var str = channel.close();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/close`"
[this ]
(-> this (.close)))
(defn name
"Property.
The read-only BroadcastChannel.name property returns a `web.dom.DOMString`,
uniquely identifies the given channel with its name. This name
passed to the `BroadcastChannel()` constructor at creation time
is therefore read-only.
`var str = channel.name;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/name`"
[this]
(-> this (.name)))
(defn onmessage
"Property.
The BroadcastChannel.onmessage event handler is a property that
the function to execute when a message event, of type `web.workers.MessageEvent`,
received by this `web.broadcast.BroadcastChannel`. Such an event
sent by the browser with a message broadcasted to the channel.
`channel.onmessage = function;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/onmessage`"
[this]
(-> this (.onmessage)))
(defn set-onmessage!
"Property.
The BroadcastChannel.onmessage event handler is a property that
the function to execute when a message event, of type `web.workers.MessageEvent`,
received by this `web.broadcast.BroadcastChannel`. Such an event
sent by the browser with a message broadcasted to the channel.
`channel.onmessage = function;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/onmessage`"
[this val]
(aset this "onmessage" val))
(defn onmessageerror
"Property.
The onmessageerror event handler of the `web.broadcast.BroadcastChannel`
is an `web.EventListener`, called whenever an `web.workers.MessageEvent`
type messageerror is fired on the BroadcastChannel instance —
is, when it receives a message that cannot be deserialized.
`bc.onmessageerror = function() { ... };`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/onmessageerror`"
[this]
(-> this (.onmessageerror)))
(defn set-onmessageerror!
"Property.
The onmessageerror event handler of the `web.broadcast.BroadcastChannel`
is an `web.EventListener`, called whenever an `web.workers.MessageEvent`
type messageerror is fired on the BroadcastChannel instance —
is, when it receives a message that cannot be deserialized.
`bc.onmessageerror = function() { ... };`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/onmessageerror`"
[this val]
(aset this "onmessageerror" val))