-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Implemented Completable#andThen(Observable) #3570
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
Adding unit tests and pushing shortly. |
02434ef
to
b92c664
Compare
*/ | ||
public final <T> Observable<T> andThen(Observable<T> next) { | ||
requireNonNull(next); | ||
return next.delaySubscription(toObservable()); |
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.
Completable
already has an endWith
overload with the same purpose.
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.
Oh, I missed that.
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.
Is there a verdict on Observable.andThen? Renaming endWith
to andThen
may serve some consistency purpose among base classes.
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.
One initial motivation for andThen
was based on the Option::and_then method in Rust stdlib. It chains through the computation and transforms it's type/contents to the next Option.
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.
My first thought was java.util.function.Function a; a.andThen(b)
. Also endWith
doesn't end the composition this would look strange a.endWith(b).endWith(c)
vs a.andThen(b).andThen(c)
.
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.
I think andThen
is more idiomatic than endWith
, especially for chaining purposes.
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.
I guess that if we are going to rename or change any of the public API on Completable now is the time before our next release. Should we aim to review the operators before next release?
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.
Yes.
TestSubscriber<String> ts = new TestSubscriber<>(0); | ||
AtomicBoolean hasRun = new AtomicBoolean(false); | ||
Exception e = new Exception(); | ||
Completable.create(cs -> cs.onError(e)) |
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.
Lambdas are Java 8. Besides, there is already a Completable.error()
and you should call cs.onSubscribe(Subscriptions.unsubscribed())
first.
b92c664
to
acaf42e
Compare
👍 |
Implemented Completable#andThen(Observable)
I expect some discussion around the method name.