-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use RES instead of "New BuckleScript Syntax" wording
- Loading branch information
Showing
3 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
type worker; | ||
|
||
[@bs.new] external make: string => worker = "Worker"; | ||
|
||
module type Config = { | ||
type fromApp; | ||
type fromWorker; | ||
let make: unit => worker; | ||
}; | ||
|
||
module Make = (Config: Config) => { | ||
include Config; | ||
|
||
module App = { | ||
[@bs.send] external postMessage: (worker, fromApp) => unit = "postMessage"; | ||
[@bs.set] | ||
external onMessage: (worker, {. "data": fromWorker} => unit) => unit = | ||
"onmessage"; | ||
[@bs.set] | ||
external onError: (worker, Js.t('a) => unit) => unit = "onerror"; | ||
[@bs.send] external terminate: worker => unit = "terminate"; | ||
}; | ||
|
||
module Worker = { | ||
type self; | ||
[@bs.val] external postMessage: fromWorker => unit = "postMessage"; | ||
[@bs.set] | ||
external onMessage: (self, {. "data": fromApp} => unit) => unit = | ||
"onmessage"; | ||
[@bs.val] external self: self = "self"; | ||
[@bs.val] external importScripts: string => unit; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters