-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
How can I use OperatorConcat<T>? #3446
Labels
Comments
Ok, well that eliminates the need for my operator, but I'm still interested in how it could be correctly implemented using lift(). I'm sure I'll be writing more operators in the future so I'd like to have a better understanding of how they work. This is what I've come up with:
|
akarnokd
changed the title
[Question] How can I use OperatorConcat<T>?
How can I use OperatorConcat<T>?
Oct 14, 2015
This is "super easy" to implement as an public final class Then<T, R> implements Operator<R, T> {
final Observable<R> other;
public Then(Observable<R> other) {
this.other = other;
}
@Override
public Subscriber<? super T> call(final Subscriber<? super R> t) {
MultipleAssignmentSubscription mas = new MultipleAssignmentSubscription();
t.add(mas);
Subscriber<T> parent = new Subscriber<T>() {
@Override
public void onNext(T t) {
// ignored
}
@Override
public void onError(Throwable e) {
t.onError(e);
}
@Override
public void onCompleted() {
Subscriber<R> tr = Subscribers.wrap(t);
mas.set(tr);
other.subscribe(tr);
}
};
mas.set(parent);
return parent;
}
} |
Awesome, thanks! I have a few questions about your solution:
Cheers! |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to write an operator
then<R,T>
which ignores all emissions from the source (except errors), and continues with a second Observable when completed.Something like:
I've come up with an implementation using
ignoreElements
+map
+concatWith
:I'm quite new to writing custom operators, and I can't quite figure out how to translate that static function into an operator. I've written a few operators by composing the provided Operator* types, but I'm having trouble with this one.
Any help would be greatly appreciated :)
The text was updated successfully, but these errors were encountered: