Last active
February 4, 2016 11:54
-
-
Save WassimBenltaief/8648663bb18cd8666289 to your computer and use it in GitHub Desktop.
PublishSubject emmiting value when a private Observable is completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String [] args) { | |
final PublishSubject<Boolean> subject = PublishSubject.create(); | |
subject.subscribe(new Observer<Boolean>() { | |
@Override | |
public void onCompleted() { | |
} | |
@Override | |
public void onError(Throwable e) { | |
} | |
@Override | |
public void onNext(Boolean aBoolean) { | |
System.out.println("Observable completed"); | |
} | |
}); | |
Observable.create(new Observable.OnSubscribe<Integer>() { | |
@Override | |
public void call(Subscriber<? super Integer> subscriber) { | |
for (int i = 0; i < 5; i++) { | |
subscriber.onNext(i); | |
} | |
subscriber.onCompleted(); | |
} | |
}).doOnCompleted(new Action0() { | |
@Override | |
public void call() { | |
subject.onNext(true); | |
} | |
}).subscribe(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment