Skip to content

Instantly share code, notes, and snippets.

@kuanyingchou
Created November 15, 2017 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuanyingchou/7ed9952230438f5c553a4d52ec320a23 to your computer and use it in GitHub Desktop.
Save kuanyingchou/7ed9952230438f5c553a4d52ec320a23 to your computer and use it in GitHub Desktop.
final Observable<String> o = Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> e) throws Exception {
for(int i=0; i<10; i++) {
if(e.isDisposed()) break;
// make request here...
e.onNext(String.valueOf(i));
try {
Thread.sleep(1000);
} catch(InterruptedException ie) {}
}
e.onComplete();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment