Created
October 1, 2018 13:41
-
-
Save CoderJava/c84fccfe5d0e21f0f9ee764cef35e0a8 to your computer and use it in GitHub Desktop.
Defer Operator RxJava
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
| public class RxOperatorDefer { | |
| public static void main(String[] args) { | |
| User user = new User(); | |
| Observable<String> name = user.getName(); | |
| user.setName("Yudi Setiawan"); | |
| name.subscribe(System.out::println); | |
| } | |
| } | |
| class User { | |
| private String name; | |
| public void setName(String name) { | |
| this.name = name; | |
| } | |
| public Observable<String> getName() { | |
| return Observable.defer(() -> Observable.just(name)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment