This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/workerpool/examples/browser/proxy.html
2020-11-01 22:46:04 +00:00

30 lines
612 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>Worker pool in the browser</title>
<script src="../../dist/workerpool.js"></script>
</head>
<body>
<script>
// create a worker pool
var pool = workerpool.pool('../workers/browserWorker.js');
// create a proxy
pool.proxy()
.then(function (proxy) {
// execute a function via the proxy
return proxy.fibonacci(10);
})
.then(function (result) {
document.write('Result: ' + result + '<br>'); // outputs 55
})
.catch(function (err) {
document.write('Result: ' + err);
});
</script>
</body>
</html>