-
-
Save Sandip124/cd94d83dda19caa5d22e96d35850fc32 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Observable<String> database = Observable //Observable. This will emit the data | |
.just(new String[]{"1", "2", "3", "4"}); //Operator | |
Observer<String> observer = new Observer<String>() { | |
@Override | |
public void onCompleted() { | |
//... | |
} | |
@Override | |
public void onError(Throwable e) { | |
//... | |
} | |
@Override | |
public void onNext(String s) { | |
//... | |
} | |
}; | |
database.subscribeOn(Schedulers.newThread()) //Observable runs on new background thread. | |
.observeOn(AndroidSchedulers.mainThread()) //Observer will run on main UI thread. | |
.subscribe(observer); //Subscribe the observer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment