summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/test/test14_emit_once.js
blob: 6b388123515c947fb3d4b7d3387947eab775e6ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var t= require('webworker-threads');

function killHandler (data) {
  console.log("GOT KILL with data -> "+ data);
  o.destroy();
}

function boot () {
  thread.once('kill', function (data) {
    thread.emit('kill', data);
  });
}

o= t.create().once('kill', killHandler).eval(boot).eval('boot()').emit('kill', "*** DATA");

process.on('exit', function () {
  console.log("Bye!");
});