Skip to content

Instantly share code, notes, and snippets.

@ccnokes
Last active February 27, 2019 21:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccnokes/d2663f474022f75591cb946d16298747 to your computer and use it in GitHub Desktop.
Save ccnokes/d2663f474022f75591cb946d16298747 to your computer and use it in GitHub Desktop.
// This works in the either the main or renderer processes.
const { requireTaskPool } = require('electron-remote');
const work = requireTaskPool(require.resolve('./work'));
console.log('start work');
// `work` will get executed concurrently in separate processes
work().then(result => {
console.log('work done');
console.log(result);
});
work().then(result => {
console.log('work done');
console.log(result);
});
work().then(result => {
console.log('work done');
console.log(result);
});
@kapilepatel
Copy link

kapilepatel commented Oct 24, 2018

Why is this code repeated 3 times?

work().then(result => {
  console.log('work done');
  console.log(result);
});

It is confusing, could you write it as

console.log('work done 1');

console.log('work done 2');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment