-
Notifications
You must be signed in to change notification settings - Fork 84
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
Do you think this Promise -> Stream conversion is a right alternative way? #194
Comments
Looks pretty reasonable. I think You've introduced pending state. The minor change is if your widget cannot return to pending state you can just initialize widget in this state and eliminate pending from stream completely. In that case you'll end up with usual |
I've experimented with some dirty approach to this, where I pass raw |
@StreetStrider Thank you for your feedback. I like the idea to pass raw I close this issue since my question is resolved. |
I'm of the opinion that this is something that should be solved in user land. The fact is we all have different use cases for converting promises, sometimes we need a loader, sometimes we want to maintain order, sometimes we just want all promises to push to a result stream. In my codebase I've used:
And in some cases depending on whether ordering must be preserved I use either I don't think flyd should prescribe to it's users how to interact with promises. |
I agree with you. |
Hello, thank you for providing this beautiful project.
Although I'm not sure whether this question should go here, I'd really like to hear opinions from this community.
As discussed #35, it seems reasonable to convert a Promise into an either-like stream.
But I noticed that I usually take another approach to convert Promise.
Here I describe my approach:
The concept behind this conversion is that "a Promise must be mapped to one of these state, 'pending' | 'fulfilled' | 'rejected'", as described here.
The first difference between this approach and
flyd.fromPromise
is that the stream created withconvertPromiseIntoStream
emits "pending state" at first.That makes it easy to know in what state a Promise is, and display some loading indicator to user.
The second difference is that the stream emits the second state, "fulfilled" | "rejected", after emitting "pending", so it is easy to filter values or reasons into a new stream and handle it.
Although I find this approach very efficient, especially building a client application, and think that it should be one of the standard Promise-Stream conversions, I'm wondering if the approach is over simplifying Promise concept, because I know nobody takes the approach and I do not have a deep knowledge in FRP.
I appreciate any feedbacks from you.
Thank you.
The text was updated successfully, but these errors were encountered: