Im using listeners as callbacks to observe asynchronous operations with Android, but I think that could be great replacing this listeners with RxJava, Im new using this libr
You are looking for Completable.create:
Completable: Represents a deferred computation without any value but only indication for completion or exception. The class follows a similar event pattern as Reactive-Streams: onSubscribe (onError|onComplete)?
Completable.create(subscriber -> {
object.getData(new OnResponseListener() {
@Override
public void onSuccess() {
subscriber.onCompleted();
}
@Override
public void onError() {
subscriber.onError(* put appropriate Throwable here *);
}
}
})
...//apply Schedulers
.subscribe((() -> *success*), (throwable -> *error*));