Created
October 14, 2015 07:37
-
-
Save Bresiu/698b354ca6ebd87d0ada 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
public class RxTest { | |
public static void main(String[] args) { | |
String str = "sty"; | |
getDoubledString(str).subscribe(new Subscriber<Integer>() { | |
@Override | |
public void onCompleted() { | |
System.out.println("on complete"); | |
} | |
@Override | |
public void onError(Throwable throwable) { | |
System.out.println("error"); | |
} | |
@Override | |
public void onNext(Integer i) { | |
System.out.println("on next: " + i); | |
} | |
}); | |
} | |
public static Observable<Integer> getDoubledString(String str) { | |
return Observable.create(new Observable.OnSubscribe<Integer>() { | |
@Override | |
public void call(Subscriber<? super Integer> subscriber) { | |
subscriber.onNext(Integer.parseInt(str)); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment