forked from rescript-lang/experimental-rescript-webapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharedWorker.res
More file actions
69 lines (52 loc) · 1.8 KB
/
SharedWorker.res
File metadata and controls
69 lines (52 loc) · 1.8 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
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
open ChannelMessagingAPI
open WebWorkersAPI
include EventTarget.Impl({
type t = sharedWorker
})
/**
`make(string)`
The SharedWorker() constructor creates a SharedWorker object that executes the
script at the specified URL. This script must obey the same-origin policy.
```res
let shared: sharedWorker = SharedWorker.make("sharedworker.js")
```
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/)
*/
@new
external make: string => sharedWorker = "SharedWorker"
/**
`makeWithName(string, string)`
The SharedWorker() constructor creates a SharedWorker object that executes the
script at the specified URL. This script must obey the same-origin policy.
```res
let shared: sharedWorker = SharedWorker.make("sharedworker.js", "name")
```
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/)
*/
@new
external makeWithName: (string, string) => sharedWorker = "SharedWorker"
/**
`makeWithOptions(string, workerOptions)`
The SharedWorker() constructor creates a SharedWorker object that executes the
script at the specified URL. This script must obey the same-origin policy.
```res
let shared: sharedWorker = SharedWorker.makeWithOptions("sharedworker.js", {
name: "workerName",
type_: Module
})
```
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/)
*/
@new
external makeWithOptions: (string, workerOptions) => sharedWorker = "SharedWorker"
/**
`port(sharedWorker)`
The port property of the SharedWorker interface returns a MessagePort object
used to communicate and control the shared worker.
```res
let port: WebAPI.ChannelMessagingAPI.messagePort = SharedWorker.port(myWorker)
```
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/port)
*/
@get
external port: sharedWorker => messagePort = "port"