forked from rescript-lang/experimental-rescript-webapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkerGlobalScope.res
More file actions
42 lines (32 loc) · 1.2 KB
/
WorkerGlobalScope.res
File metadata and controls
42 lines (32 loc) · 1.2 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
open WebWorkersAPI
open FetchAPI
module Impl = (
T: {
type t
},
) => {
include EventTarget.Impl({type t = T.t})
/**
`fetch(workerGlobalScope, string, init)`
The fetch() method of the WorkerGlobalScope interface starts the process of fetching a resource from the network,
returning a promise that is fulfilled once the response is available.
```res
let response = await self->WorkerGlobalScope.fetch("https://rescript-lang.org")
```
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/fetch)
*/
@send
external fetch: (T.t, string, ~init: requestInit=?) => promise<response> = "fetch"
/**
`fetch_withRequest(workerGlobalScope, request, init)`
The fetch() method of the WorkerGlobalScope interface starts the process of fetching a resource from the network,
returning a promise that is fulfilled once the response is available.
```res
let response = await self->WorkerGlobalScope.fetch(myRequest)
```
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/fetch)
*/
external fetch_withRequest: (T.t, request, ~init: requestInit=?) => promise<response> = "fetch"
external self: T.t = "self"
}
include Impl({type t = workerGlobalScope})