File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
src/com/blankj/custom/rxjava Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ public class Observable<T> {
4
4
//接口,每个Observable里面有一个OnSubscribe对象,只有一个方法(void call(Subscriber<? super T> subscriber);),
5
5
// 用来产生数据流,这是典型的命令模式。
6
6
public interface OnSubscribe <T > {
7
- void call (Subscriber <? super T > subscriber );
7
+ // void call(Subscriber<? super T> subscriber);
8
+ void call (Subscriber <T > subscriber );
8
9
}
9
10
10
11
//接口实现类
@@ -20,9 +21,9 @@ public static <T> Observable<T> create(OnSubscribe<T> onSubscribe) {
20
21
return new Observable <T >(onSubscribe );
21
22
}
22
23
23
- public void subscribe (Subscriber <? super T > subscriber ) {
24
+ public void subscribe (Subscriber <T > subscriber ) {
24
25
System .out .println ("will call subscriber" );
25
- subscriber .onStart ();
26
+ // subscriber.onStart();
26
27
//onSubscribe来call这个subscriber
27
28
onSubscribe .call (subscriber );
28
29
}
Original file line number Diff line number Diff line change 2
2
3
3
public abstract class Subscriber <T > implements Observer <T > {
4
4
//抽象类可以抽象方法,或者具体实现,此处为具体实现
5
- public void onStart () {
6
- }
5
+ // public void onStart() {
6
+ // }
7
7
}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ public static void main(String[] args) {
5
5
Observable .create (new Observable .OnSubscribe <Integer >() {
6
6
//实例化接口实现类,需要override
7
7
@ Override
8
- public void call (Subscriber <? super Integer > subscriber ) {
8
+ public void call (Subscriber <Integer > subscriber ) {
9
9
System .out .println ("call method execute" );
10
10
for (int i = 0 ; i < 10 ; i ++) {
11
11
System .out .println ("Prepare data " + i );
You can’t perform that action at this time.
0 commit comments