rsvp/test/worker.js
raw| 1 | self.importScripts('../rsvp.js'); |
| 2 | new RSVP.Promise(function(resolve, reject) { |
| 3 | self.onmessage = function (e) { |
| 4 | if (e.data === 'ping') { |
| 5 | resolve('pong'); |
| 6 | } else { |
| 7 | reject(new Error('wrong message')); |
| 8 | } |
| 9 | }; |
| 10 | }).then(function (result) { |
| 11 | self.postMessage(result); |
| 12 | }, function (err){ |
| 13 | setTimeout(function () { |
| 14 | throw err; |
| 15 | }); |
| 16 | }); |