Reactive Programming on Android with RxJava by Christopher Arriola & Angus Huang

Reactive Programming on Android with RxJava by Christopher Arriola & Angus Huang

Author:Christopher Arriola & Angus Huang
Language: eng
Format: azw3, epub, pdf
Publisher: leanpub.com
Published: 2017-06-29T07:00:00+00:00


Observable.subscribeOn()

The .subscribeOn() operator is used in the Observable chain to dictate where the Observable should operate (i.e. the function inside of .create()). Rewriting the previous example using a Scheduler instead gives us:

1 Observable<Integer> integerObservable = Observable.create(source -> { 2 Log.d(TAG, "In subscribe"); 3 source.onNext(1); 4 source.onNext(2); 5 source.onNext(3); 6 source.onComplete(); 7 }); 8 Log.d(TAG, "Created Observable"); 9 10 Log.d(TAG, "Subscribing to Observable"); 11 integerObservable.subscribeOn(Schedulers.newThread()) 12 .subscribe(i -> Log.e(TAG, "In onNext(): " + i)); 13 14 Log.d(TAG, "Finished");



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.