Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rescript-worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

43 changes: 43 additions & 0 deletions rescript-worker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# rescript-worker
> Zero-cost bindings for Web API [Worker](https://www.w3.org/TR/workers)


## Installation

Run the following in your favorit console:
```console
> yarn add rescript-worker
```

**OR**

```console
> npm install --save rescript-worker
```

Then, add `rescript-worker` in your `bsconfig.json`:

```diff
-- "bs-dependencies": [],
++ "bs-dependencies": ["rescript-worker"],
```

## Usage

```rescript
// construct
let abortController = AbortController.new()

let worker = Worker.new("ourworker.js")
let workerWithOptions = Worker.newWithOptions("",{"optKey": "optValue"})

```

Or you can check this [**examples**](https://github.com/ri7nz/rescript-libs/tree/main/examples/dev/dev__worker.res).

## API
> (WIP)

## Reference
* https://www.w3.org/TR/workers
* https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API
11 changes: 11 additions & 0 deletions rescript-worker/bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "rescript-worker",
"sources": {
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "es6",
"in-source": true
}
}
29 changes: 29 additions & 0 deletions rescript-worker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "rescript-worker",
"version": "0.0.1",
"description": "zero-cost bind for Web Workers API",
"keywords": [
"web-api",
"rescript",
"web-worker",
"worker",
"Web-Workers-API"
],
"author": "ri7nz <hi@rin.rocks>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/ri7nz/rescript-libs.git",
"directory": "rescript-worker"
},
"scripts": {
"start": "rescript build -w",
"build": "rescript build -with-deps"
},
"bugs": {
"url": "https://github.com/ri7nz/rescript-libs/issues"
},
"devDependencies": {
"rescript": "9.1.1"
}
}
2 changes: 2 additions & 0 deletions rescript-worker/src/Worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions rescript-worker/src/Worker.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type t

@new
external new: string => t = "Worker"

@new
external newWithOptions: (string, {..}) => t = "Worker"