自己模仿了一遍rxjava泛型

package com.example.administrator.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //        Subscription subscribe = Observable.create(new Observable.OnSubscribe() {
        //            @Override
        //            public void call(Subscriber subscriber) {
        //
        //            }
        //        }).subscribe(new Action1() {
        //            @Override
        //            public void call(String s) {
        //
        //            }
        //        });

        Observable.create(
                new OnSubscribe() {
                    @Override
                    public void call(Subscriber subscriber) {

                    }
                }
        ).subscribe(new Action1() {
            @Override
            public void call(String s) {

            }
        });


    }
}


package com.example.administrator.myapplication;

/**
 * Created by xieguofeng on 2018/5/11
 */
interface Action1 {
    void call(T t);
}

package com.example.administrator.myapplication;

/**
 * Created by xieguofeng on 2018/5/11
 */
public class Observable {

    public  static  Observable create(OnSubscribe onSubscribe) {
        return new Observable();
    }

    public Observable subscribe(Action1 action1){
        return this;
        //....
    };
}

package com.example.administrator.myapplication;

/**
 * Created by xieguofeng on 2018/5/11
 */
interface OnSubscribe {
    void call(Subscriber subscriber);
}

package com.example.administrator.myapplication;

/**
 * Created by xieguofeng on 2018/5/11
 */
public abstract class Subscriber {

}

你可能感兴趣的:(自己模仿了一遍rxjava泛型)