Skip to content

Instantly share code, notes, and snippets.

@Bresiu
Created October 14, 2015 07:37
Show Gist options
  • Save Bresiu/698b354ca6ebd87d0ada to your computer and use it in GitHub Desktop.
Save Bresiu/698b354ca6ebd87d0ada to your computer and use it in GitHub Desktop.
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