我正在从http://blog.danlew.net/2014/09/15/grokking-rxjava-part-1/学习 RxJava
复制并粘贴他的 hello world 示例会产生一个编译错误,指出该方法没有覆盖超类中的方法。所以我使用了相同的示例,但让 Eclipse 生成了“调用”方法:
Observable<String> myObservable = Observable.create(
new Observable.OnSubscribe<String>() {
public void call(Subscriber<? super String> arg0) {
// TODO Auto-generated method stub
System.out.println("Hi");
arg0.onNext("Hello, world!");
arg0.onCompleted();
}
}
);
运行上面的代码不会打印任何东西,验证 call 方法从未被调用过。
我的 build.gradle 文件:
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version':
version
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
compile 'io.reactivex:rxjava:1.0.0'
}
test {
systemProperties 'property': 'value'
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
如果有人可以在 rxjava 或 rxandroid 上链接一个很棒的、直观的教程,那也将不胜感激。