-
-
Notifications
You must be signed in to change notification settings - Fork 81
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.fold() #47
Promise.fold() #47
Conversation
Thank you @oltrep! I'm curious - is there a cancellation behavior that needs to be supported here from the reference implementation (or to align with the other utilities in this library). |
Thank you for the PR! I will review this next week. I'm on vacation this week |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I have requested some changes. Notably, we should always return a Promise from Promise.fold, so as to be in accordance with the other functions and for consistency.
You can take advantage of chaining so you don't have to inspect the values directly: https://eryn.io/roblox-lua-promise/lib/Tour.html#chaining
This function also has no cancellation semantics. You can read about cancellation here: https://eryn.io/roblox-lua-promise/lib/Tour.html#cancellation
If we instead implement Promise.fold
over top of Promise.each
, we get those cancellation and chaining semantics for free. How does that sound?
Thanks again!
I think I've addressed all your comments, let me know if you find something else :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contributions! Looks good.
Closes #46
As discussed in the issue, here is the PR for
Promise.fold
!Let me know if you have any comments/improvements :)