如何从以下代码获取返回值:
CompositeDisposable mCompositeDisposable = new CompositeDisposable();
mCompositeDisposable.add(observableSubject(userName, password)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(@NonNull Disposable disposable) throws Exception {
}
})
.doFinally(new Action() {
@Override
public void run() throws Exception {
}
})
.subscribeWith(new DisposableObserver<String>() {
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(String res) {
//I need to get value from out of mCompositeDisposable.add(...)
Log.i("LOG", res);
}
}));
然后:
private Observable<String> observableSubject(String userName, String password) {
return Observable.defer(() -> {
//Some Code
return Observable.just("Value");
});
}
答案 0 :(得分:0)
我通过这种方法解决了<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.group-name</groupId>
<artifactId>my-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>2.12.6</version>
</dependency>
<dependency>
<groupId>org.opencypher</groupId>
<artifactId>spark-cypher</artifactId>
<version>0.1.5</version>
</dependency>
</dependencies>
</project>
的问题:
EventBus