Closed SMontiel closed 6 years ago
It is beyond the scope of this project and I think RxJava offers more behavior, such as retrying a flow which you don't have to rebuild from scratch.
Well it is true, but Promises based on RxJava could offer more behavior. So I will develop as a separated library, just to have something similar to JavaScript promises. :smile: Or what's your opinion?
They exist as CompletableFutures and CompletionStage in Java at least and there exist several backports. I think learning the ReactiveX style of asynchronous programming first helps you understand Promises and other one element async approaches better. Of course, for educational purposes, you are welcome to implement your own library, which can give you nice insights into the standard concurrency abstractions and tools of Java.
But that was added to Java 8, right? There is nothing for Java 7 or 6, or am I wrong?
I am starting to develop the library, I'll do it based on RxJava's architecture, just to have something closer to JavaScript's promises and to learn the core concepts of RxJava. I will show you when it's done. Thank you for your time more than anything else! :smile:
Good luck!
It is done, @akarnokd! Check it out here! Documentation are missing. Some feedback?
It pretty much looks like Single without cancellation support. Also afaik promises are supposed to be hot, i.e. representing an ongoing or terminated computation.
Mmm yeah, it is like Single I was thinking about that if it have to be cold or hot, I'll be working on that. When you say 'representing or terminated computation' you refer to Promise's states(FULFILLED, REJECTED and PENDING? In the first call to done() I'll be caching that value(value or Throwable) and state, so next calls will be returning that value or Throwable, this is my idea. am I right? do you have a better idea (yes, you have)?
I meant what's written here.
For such cached state, there is the SingleSubject.
What do you all think about Promises based on RxJava, buddies? Some like this:
Output:
Is it a good idea add it into RxJava or as a separated library?