Skip to content

Instantly share code, notes, and snippets.

@squm
Created September 30, 2015 06:16
Show Gist options
  • Save squm/398a6f2f2ff5d90d0f42 to your computer and use it in GitHub Desktop.
Save squm/398a6f2f2ff5d90d0f42 to your computer and use it in GitHub Desktop.
private CompositeSubscription composite;
// ...
@Override
protected void onCreate(Bundle savedInstanceState) {
composite = new CompositeSubscription();
}
@Override
protected void onDestroy() {
super.onDestroy();
composite.unsubscribe();
}
// ...
Func0<Observable<String>> selSignin = new Func0<Observable<String>>() {
@Override
public Observable<String> call() {
final String error = "no error";
return Observable.just(error);
}
};
Action1<String> sel = new Action1<String>() {
@Override
public void call(final String error) {
if (error == null) {
}
else {
}
}
};
composite.clear();
Subscription sub =
Observable
.defer(selSignin)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(sel)
;
composite.add(sub);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment