-
Notifications
You must be signed in to change notification settings - Fork 67
Add forkAll combinator #45
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
Conversation
forkAll :: forall f e a. (Foldable f) => f (Aff e a) -> Aff e Unit | ||
``` | ||
|
||
Forks many asynchronous computation at once, ignoring the results. |
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.
It would be good to add a guarantee that all computations will be forked synchronously.
I went ahead and made it mirror |
@natefaubion 👍 Looks great, @garyb you want to do a final review? |
Will do, once 2.5 is out! |
acc.push(aff(voidF, voidF)); | ||
return acc; | ||
} | ||
})([])(affs); |
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.
🙈
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.
Hah. I don't love it either :/
I might be able to extract out a helper to share with cancelWith.
On Feb 22, 2016, at 4:11 AM, Gary Burgess [email protected] wrote:
In src/Control/Monad/Aff.js:
@@ -96,6 +96,61 @@ exports._forkAff = function (nonCanceler, aff) {
};
}+exports._forkAll = function (nonCanceler, foldl, affs) {
- var voidF = function(){};
- return function(success, error) {
- var cancelers = foldl(function(acc) {
return function(aff) {
acc.push(aff(voidF, voidF));
return acc;
}
- })([])(affs);
—
Reply to this email directly or view it on GitHub.
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.
Nah, I can see it's fine, it's just the mutating of the array in the fold while constructing it that made me look twice. 😄
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.
Ah. Thought you were referring to the sheer length of this function. Hard to tell in email sometimes
Looks good to me too! 👍 |
No description provided.