@@ -25,33 +25,31 @@ protected void doSomeWork() {
2525 mSubscription .cancel ();
2626 }
2727
28- Flowable .range (0 , 20 )
28+ Flowable .range (0 , 20 )
2929 .subscribeOn (Schedulers .io ())
30- .observeOn (AndroidSchedulers .mainThread ())
30+ .observeOn (AndroidSchedulers .mainThread ())
3131 .subscribeWith (new Subscriber <Integer >() {
3232
3333 //当订阅后,会首先调用这个方法,其实就相当于onStart(),
3434 //传入的Subscription s参数可以用于请求数据或者取消订阅
3535 @ Override
3636 public void onSubscribe (Subscription s ) {
37- FlowableExampleActivity .this .onSubscribe ("" ,null );
37+ FlowableExampleActivity .this .onSubscribe ("" , null );
3838 mSubscription = s ;
3939 //要说明一下,request这个方法若不调用,下游的onNext与OnComplete都不会调用;
4040 // 若你写的数量小于真实数据量,只会传你的个数,而且不会调用onComplete方法(毕竟没有传完嘛,当然没有complete)
41- // mSubscription.request(10);
4241 mSubscription .request (1 );
4342 }
4443
4544 @ Override
4645 public void onNext (Integer o ) {
47- // SystemClock.sleep(1000);
48- FlowableExampleActivity .this .onNext ("" ,o );
46+ FlowableExampleActivity .this .onNext ("" , o );
4947 mSubscription .request (1 );
5048 }
5149
5250 @ Override
5351 public void onError (Throwable t ) {
54- FlowableExampleActivity .this .onError ("" ,t );
52+ FlowableExampleActivity .this .onError ("" , t );
5553 }
5654
5755 @ Override
@@ -60,25 +58,13 @@ public void onComplete() {
6058 }
6159 });
6260
63-
64- // Flowable<Integer> observable = Flowable.just(1, 2, 3, 4);
65- //
66- // observable.reduce(50, new BiFunction<Integer, Integer, Integer>() {
67- // @Override
68- // public Integer apply(Integer t1, Integer t2) {
69- // return t1 + t2;
70- // }
71- // }).subscribe(getObserver());
72-
7361 }
7462
75-
7663 @ Override
7764 protected void onDestroy () {
78- if (mSubscription != null ) {
65+ if (mSubscription != null ) {
7966 mSubscription .cancel ();
8067 }
8168 super .onDestroy ();
82- // mCompositeDisposable.dispose();
8369 }
8470}
0 commit comments