-
Notifications
You must be signed in to change notification settings - Fork 95
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
Promise.resolve(thenable) executes thenable.then synchronously #105
Comments
Confirmed, and more. Promise.resolve(whatever) should not be invoking the whatever at all, either synchronously or asynchronously. Remember, this is only a renaming of Promise.cast. It should only do a brand check to determine if it is a real promise or not. If it is, it must return it. If it isn't, it must wrap it. For this operation, if whatever is not a real promise, it does not even matter whether it is a thenable or not, as it is being wrapped in the same way regardless. |
I think "being wrapped in the same way" might have a subtle nuance that's being lost, perhaps. Wrapped, yes. In the same way? Does it actually have to be? Here's what I mean: If But, from a performance optimization perspective, it would seem that In other words: x = 10;
y = Promise.resolve(2);
z = 20; In that snippet, all 3 actions are taken synchronously, and there's nothing else to complete on the next cycle, like fulfilling the Or am I missing something that makes that unacceptable? |
Spec's only traffic in observables. Any change which is unobservable is On Sat, May 10, 2014 at 3:08 PM, Kyle Simpson [email protected]:
Text by me above is hereby placed in the public domain Cheers, |
@getify the wording of immediately fulfilled promise is potentially confusing as a sequence of two operations occur.
As the consumer is at best notified nextTurn the perspective of the system is promises are async. |
Your "in the same way" seemed to me to over-constrain what should have just been an implementation detail, but the spirit of my question was to make sure I wasn't missing some way that |
I know that is not place for that but i need help. I'm trying to implement for my own http://promisesaplus.com and i'm stock almost at the end. I dont know what i'm doing wrong. Test looks like:
Code is under: https://github.com/stopsopa/ipromise Or tell me please where to go to get help :D |
From getify/native-promise-only#5
As I understand it, this is really bad, as then the thenable can break the surrounding code's invariants. @erights @kriskowal can confirm.
I think the fix for this is pretty simple, and will be proposing it in a pull request shortly. (Just wrap the
then
call in an EnqueueTask, essentially).The text was updated successfully, but these errors were encountered: