Skip to content

Instantly share code, notes, and snippets.

@h-hub
Created December 1, 2018 20:31
Show Gist options
  • Save h-hub/f656898b9e44677df185de3baa711b0f to your computer and use it in GitHub Desktop.
Save h-hub/f656898b9e44677df185de3baa711b0f to your computer and use it in GitHub Desktop.
public class ObservablesRun {
public static void main(String[] args) {
List<String> symbols = Arrays.asList("GOOG", "AAPL", "MSFT", "INTC");
Observable<StockInfo> feed = StockServer.getFeeed(symbols);
Disposable subscribe = feed.subscribeWith(new DisposableObserver<StockInfo>() {
int count = 0;
@Override
public void onNext(StockInfo t) {
System.out.println(t);
count++;
if (count == 10) {
dispose();
}
}
@Override
public void onError(Throwable e) {
System.out.println("ERROR");
}
@Override
public void onComplete() {
System.out.println("DONE");
}
});
System.out.println("Got observable");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment