-
Notifications
You must be signed in to change notification settings - Fork 9
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.all propagates resolved values into the catch handler. #7
Comments
I agree with you. But this is a implement of Promises/A+, and However, refer to mozilla's javascript doc about
So I think function function Promise.all(...)
local promises = {...}
local results = {}
local state = State.FULFILLED
local remaining = #promises
local promise = Promise.new()
for i,p in ipairs(promises) do
p:next(
function(value)
results[i] = value
remaining = remaining - 1
if remaining == 0 then
transition(promise, State.FULFILLED, results)
end
end,
function(value)
transition(promise, State.REJECTED, value)
end
)
end
if remaining == 0 then
transition(promise, State.FULFILLED, results)
end
return promise
end |
I agree with jojo59516. The idea behind following the Promises/A+ spec is to provide consistency between implementations, and the change they propose would do exactly that. |
…pi, resolves issue Billiam#7
…pi, resolves issue Billiam#7
For
Promise.all()
, when some promises are resolved, and some rejected, the catch handler receives all values.This makes it really hard to tell which are errors and which aren't.
Outputs this:
I would like to have:
The text was updated successfully, but these errors were encountered: