Created
December 1, 2018 20:31
-
-
Save h-hub/f656898b9e44677df185de3baa711b0f to your computer and use it in GitHub Desktop.
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 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