securityos/node_modules/comlink/docs/examples/02-callback-example/index.html

18 lines
414 B
HTML
Raw Normal View History

2024-09-06 15:32:35 +00:00
<!DOCTYPE html>
<script type="module">
import * as Comlink from "https://unpkg.com/comlink/dist/esm/comlink.mjs";
// import * as Comlink from "../../../dist/esm/comlink.mjs";
function callback(value) {
alert(`Result: ${value}`);
}
async function init() {
const remoteFunction = Comlink.wrap(new Worker("worker.js"));
await remoteFunction(Comlink.proxy(callback));
}
init();
</script>