forked from baiiu/AndroidModule
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateFragment.java
More file actions
94 lines (81 loc) · 3.04 KB
/
Copy pathCreateFragment.java
File metadata and controls
94 lines (81 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.baiiu.rxjava2study;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import com.baiiu.library.LogUtil;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.Single;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
/**
* author: baiiu
* date: on 17/5/12 11:38
* description:
*/
class CreateFragment extends Fragment {
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Observable.just("abc")
.subscribe(new Consumer<String>() {
@Override public void accept(@NonNull String s) throws Exception {
LogUtil.d("accept:" + s);
}
}, new Consumer<Throwable>() {
@Override public void accept(@NonNull Throwable throwable) throws Exception {
LogUtil.d("accept:" + throwable.toString());
}
}, new Action() {
@Override public void run() throws Exception {
LogUtil.d("onComplete");
}
});
Observable.just("a")
.subscribe(System.out::println);
Observable.just("ab")
.subscribe(new Observer<String>() {
@Override public void onSubscribe(@NonNull Disposable d) {
LogUtil.d("onSubscribe");
}
@Override public void onNext(@NonNull String s) {
LogUtil.d("onNext: " + s);
}
@Override public void onError(@NonNull Throwable e) {
LogUtil.d("onError: " + e.toString());
}
@Override public void onComplete() {
LogUtil.d("onComplete");
}
});
Single.just("e")
.subscribe(new Consumer<String>() {
@Override public void accept(@NonNull String s) throws Exception {
LogUtil.d(s);
}
});
//Flowable.create(new FlowableOnSubscribe<String>() {
// @Override public void subscribe(@NonNull FlowableEmitter<String> emitter) throws Exception {
//
// }
//}, BackpressureStrategy.DROP)
// .subscribe(new FlowableSubscriber<String>() {
// @Override public void onSubscribe(@NonNull Subscription s) {
//
// }
//
// @Override public void onNext(String s) {
//
// }
//
// @Override public void onError(Throwable t) {
//
// }
//
// @Override public void onComplete() {
//
// }
// });
}
}