ember-introjs
Version:
An Ember Component for intro.js
30 lines (25 loc) • 768 B
JavaScript
// This example worker runs asynchronous tasks. In practice, this could be
// interacting with a database or a web service. The asynchronous function
// returns a promise which resolves with the task's result.
var workerpool = require('../../index');
// an async function returning a promise
function asyncAdd (a, b) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve(a + b);
}, 1000);
});
}
// an async function returning a promise
function asyncMultiply (a, b) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve(a * b);
}, 1000);
});
}
// create a worker and register public functions
workerpool.worker({
asyncAdd: asyncAdd,
asyncMultiply: asyncMultiply
});