octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.36k stars 957 forks source link

Implement callbacks #27

Open Multiply opened 9 years ago

Multiply commented 9 years ago

I want to do something like

robot.moveMouseSmoothly(x, y, function(coordinates, oldCoordinates) {
  console.log('Done moving');
});

Would this be possible to do for all methods, so we can chain them properly, and so the methods are not blocking.

octalmage commented 9 years ago

This is probably way better than #14, it's the Node.js way to do things.

Thanks for the suggestion, I'll keep it in mind.

kilianc commented 9 years ago

Better if returns a promise, a callback that doesn't have err as first parameter is not standard and not yieldable :)

Looks like we have no err to report, and having always nil seems unnecessary

octalmage commented 9 years ago

I'm still not sure how I should handle this, but I think it would be best to use callbacks with a delay in the C code. This way the commands are chainable, the delay is non-blocking, and we won't run into any OS limitations.

skibz commented 9 years ago

callbacks :+1:

marcio199226 commented 5 years ago

Will be this feature implemented in any future releases ?

ricardopolo commented 4 years ago

Promises, async/await 👍