1、create
/**
* creat是一个比较原始的创建Obserable的操作符
*/
private static void test01(){
//正常调用形式
// Observable.create(new ObservableOnSubscribe<String>() {
// @Override
// public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
// emitter.onNext("emitter Obervable");
// emitter.onComplete();
// }
// })
//lamda 表达式形式
Observable.create((ObservableOnSubscribe<String>) emitter -> {
emitter.onNext("---emitter Obervable");
emitter.onComplete();
}).subscribe(new Observer<String>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
System.out.println("onSubscribe"+d.toString());
}
@Override
public void onNext(@NonNull String s) {
System.out.println("onNext"+s.toString());
}
@Override
public void onError(@NonNull Throwable e) {
System.out.println("onError"+e.toString());
}
@Override
public void onComplete() {