what's the usage of evaluateAsync
and when we have to use this function and what's the benefit of using this function .
in the below we see a poor documentation for this :
var webPage = require('webpage');
var page = webPage.create();
// @TODO: Finish page.evaluateJavaScript example.
any body can show a example of usage of evaluateAsync
in phantomjs
This function allows you to execute any JavaScript code like the evaluate
API function.
But it will evaluate your code asynchronous. It means:
Let's say you want execute some long-running JavaScript code, but you don't interested in its result. If you will use evaluate
, your current execution context will be blocked.
The documentation for evaluateAsync
is a bit wrong. The correct signature for evaluateAsync
is:
evaluateAsync(function, ms, args)
, where:
Example:
evaluateAsync(function() {
console.log('Hi! I\'m evaluateAsync call!');
}, 1000);
Using in the real world:
evaluateAsync
to run unit tests.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With