forked from deebloo/worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
47 lines (39 loc) · 1.07 KB
/
demo.html
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
36
37
38
39
40
41
42
43
44
45
46
47
<!doctype html>
<html>
<head>
<title>web worker example</title>
</head>
<body>
<h1>Look In The Console</h1>
<script src="src/worker.js"></script>
<script>
var workers = $worker();
var worker1 = workers.create(function (e) {
self.postMessage(e.data);
}, [
{
name: 'foo',
method: function () {
return 'Hello World';
}
}
]);
var worker2 = workers.create(function (e) {
self.postMessage(e.data);
});
var worker3 = workers.create(function (e) {
self.postMessage(e.data);
});
workers
.runAll('Hello World')
.then(function (e) {
return e.map(function (evt) {
return evt.data;
});
})
.then(function (e) {
console.log(e);
});
</script>
</body>
</html>