-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample.html
More file actions
35 lines (31 loc) · 796 Bytes
/
example.html
File metadata and controls
35 lines (31 loc) · 796 Bytes
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
<html>
<head>
<title>Worker</title>
</head>
<body>
<script src="build/build.js"></script>
<script>
// streaming
(function(){
var Worker = require('worker');
var worker = new Worker('workers/progress.js');
worker.on('message', function(msg, e){
if (!msg.progress) return worker.off('message');
console.log(msg.progress);
});
worker.send({ id: 1 });
});
// request response
(function(){
var Worker = require('worker');
var uppercase = new Worker('workers/callback.js');
uppercase.send({ value: 'hello' }, function(res){
console.log(res.value);
uppercase.send({ value: 'world' }, function(res){
console.log(res.value);
});
});
})();
</script>
</body>
</html>