-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use as a 1:1 replacement of window.Promise? #2
Comments
Excellent question. Please see this section of the README. I am not suprised that you got an infinite loop. In order to maximize performance, SPromiseMeSpeed does not delay until the next tick before executing the handle: console.log("before");
SPromise.resolve().then(function(){
console.log("inside");
});
console.log("after"); Will yield:
Whereas an ordinary browser promise console.log("before");
Promise.resolve().then(function(){
console.log("inside");
});
console.log("after"); will yield:
Coding using SPromise has to be written with the mindset that the delay is not guaranteed. Your react app is probably getting stuck because the code inside the Further, SPromise reserves the right to switch up the order of execution of deeply nested Promises in order to prevent stack overflows, and this allows for the infinite loop you are experiencing. When SPromise detects too many nested levels of promises (creating a promise inside the That being said, I don't think SPromise is a danger to most projects (in terms of increasing the liklihood of bugs). You just have to approach SPromise the right way, and your code will be fine. Infact, I would argue that SPromise sometimes makes things easier to debug because interwoven asynchronous stack traces can sometimes be hard to follow and SPromises eliminates all possible asynchrony. I hope this helps. |
Thanks for the clear explanation. |
I'd be really curious to try it on a Promise heavy app.
UPDATE:
I tried in a React application, I've got an infinite loop unfortunately :(
The text was updated successfully, but these errors were encountered: