Created
October 17, 2015 18:26
-
-
Save Fi5t/7fb2a2c9f0e96cc13b18 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
final Scheduler scheduler = Schedulers.from(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())); | |
Observable.just("1", "2", "3", "4", "5") | |
.flatMap(id -> loadFileById(scheduler, id)) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(s2 -> hello.setText(hello.getText() + "\n" + s2)); | |
private Observable<String> loadFileById(final Scheduler scheduler, final String id) { | |
return Observable.defer( | |
() -> Observable.just(id) | |
.map(s -> "<" + Thread.currentThread().getName() + ">" + s) // <- put loading method here | |
).subscribeOn(scheduler); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment