Last active
April 4, 2020 09:25
-
-
Save kevalpatel2106/c1527a89cea2add156e4709f183da189 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
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