Closed sodawy closed 8 years ago
What do you mean by cancel?
If you don't want resolve
to be called by your success event listener, a common way to prevent double resolving or rejecting is by overwriting resolve
or reject
with an empty function, like Function.prototype
.
phantom.run(function (resolve, reject) {
page.open("http://www.google.com", function () {
resolve(text);
});
// oops, I don't want this anymore
resolve = Function.prototype;
reject(new Error("I'm outta here!"));
})
Does this solve your issue?
how about change the promise lib to bluebird, which is more popular, better api and performance.
With the next major version, phridge will just use the global Promise
object. Then you can use your own library.
"next major" sounds great~
the cancel i want:
javascript
when.promise(function(resolve, reject){
if(somecase){
cancel(); //thenA and thenB block will not be entered
}
}).then(function(){//then A
}).then(function(){//then B
})
thanks again~
That's basically what reject()
does.
phridge 2.0.0
shipped today with native promises
I want cancel or abort a running page, but the when promise cannot cancel.
Is there some way to abort the running promise with no exception like
Cannot call reject() after the promise has already been resolved or rejected
?how about change the promise lib to bluebird, which is more popular, better api and performance.
thx!