org.polkadot.utils.RxUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polkadot-java Show documentation
Show all versions of polkadot-java Show documentation
Java Polkadot API, this is a clone of https://github.com/polkadot-java/api
The newest version!
package org.polkadot.utils;
import com.onehilltech.promises.Promise;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
public class RxUtils {
public static Observable fromPromise(Promise promise) {
return Observable.create(new ObservableOnSubscribe() {
@Override
public void subscribe(ObservableEmitter emitter) throws Exception {
promise.then((result) -> {
emitter.onNext(result);
emitter.onComplete();
return null;
})._catch(err -> {
emitter.onError(err);
return null;
});
}
});
}
public static Observable fromPromise(Promise promise, ObservableOnSubscribe observableOnSubscribe) {
return Observable.create(observableOnSubscribe);
}
}