-
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
Future.finally #71
Comments
No comments on this? I am using futures right now in production and feel as if I need this badly. Could it be added or should the entire model be reconsidered as mentioned before? Ping! @buzzdecafe @scott-christopher @davidchambers @CrossEye @DrBoolean |
Do you find yourself doing something like this? fut.fork(err => {
// do X...
// do Z...
},
val => {
// do Y...
// do Z...
}); Perhaps you could share a concrete example? |
Yes that is is. |
What are you suggesting, exactly? Something like this? fut.forkFinally(err => {
// do X...
},
val => {
// do Y...
},
() => {
// do Z...
}); |
I'm sorry, I've not paid much attention to R-F lately, nor at all to I really should, as I needed something like it lately and automatically reached for |
I would personally find it odd, and I would probably resist changing I can certainly understand the rationale, but it strikes me that this might well have to be in the user's control. Perhaps such a function should run before a So neither 👍 nor 👎 from me. But the good news is that I dropped this in where I was using Folktale's data.Task, and it worked without a hitch. This is the first time I've actually used R-F for any production code. It's nice to see it working well. Kudo's to those who've been putting in the effort here. |
This is what I am doing right now and I really dislike it. It is duplication The most important thing to me is the rationale as you say @CrossEye. I am open to suggestions on how to make it work. It does not have to be something called "finally", perhaps there are even better solutions. But what about... (just thinking on the top of my head here)
Did a quick test on my machine with this and it allows:
Works when the future succeeds, fails and does not supply a finally function. |
The idea seems reasonable, but it makes the type signature pretty messy:
|
I guess my concern is that I see nothing intrinsic to make us add an 'after' without a 'before'. In David's notation earlier, fut.fork(err => {
// do W...
// do X...
// do Z...
},
val => {
// do W...
// do Y...
// do Z...
}); Should this not be translated at fut.forkFinally( () =>
// do W...
},
err => {
// do X...
},
val => {
// do Y...
},
() => {
// do Z...
}); And that makes the type signature still worse: Future#fork :: Future a =>
{ initially :: () -> () } -> (Error -> ()) -> (a -> ()) -> { finally :: () -> () } If you don't want to do this, then why does 'after' get such precedence over 'before'?
I like this API, if we decide to go with a |
Should there be an equivalence of a
finally
statement on futures? I recently used that with promises and I wondered how I would solve the same situation with futures. Folktale has a cleanup method but it is supplied with the constructor. To me that seems a bit weird. Should it not be called together withfork
?Thoughts?
The text was updated successfully, but these errors were encountered: