Re: [streams] Why is the reference implementation calling promise callbacks synchronously? (#293)

Yep, that makes sense.
I should have had a second look at the test results obviously!
Thanks

2015-03-11 16:27 GMT+01:00 Domenic Denicola <notifications@github.com>:

> The reference implementation isn't calling promise callbacks
> synchronously. Instead, it is resolving/rejecting the promise, which itself
> will schedule the callbacks asynchronously. Here is an example with just
> promises that may be helpful to understand:
>
> let resolve;const promise = new Promise(r => { resolve = r; });
>
> promise.then(v => console.log("fulfilled", v));
>
> resolve(5);console.log("after resolve call");
>
> This will print "after resolve call"\n"fulfilled 5". Even though
> resolve(5) is called "synchronously", the way promises are specified
> ensures that any callbacks are scheduled to run asynchronously.
>
> Make sense?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/whatwg/streams/issues/293#issuecomment-78285808>.
>


---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/293#issuecomment-78358630

Received on Wednesday, 11 March 2015 20:01:43 UTC