GithubHelp home page GithubHelp logo

rxbus2-1's Introduction

RxBus2

Rxbus2 by rxjava2.0

used

Gradle

compile 'lib.gorden.rxbus2:rxbus:2.0.1'

Maven

<dependency>
  <groupId>lib.gorden.rxbus2</groupId>
  <artifactId>rxbus</artifactId>
  <version>2.0.1</version>
  <type>pom</type>
</dependency>

使用介绍

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        RxBus.get().register(this);
    }


    public void test1005(View view){
        RxBus.get().send(1005);
    }
    public void test1005String(View view){
        RxBus.get().send(1005,"字符串数据");
    }
    public void test1005Int(View view){
        RxBus.get().send(1005,1303);
    }
    public void test1005Object(View view){
        RxBus.get().send(1005,new ArrayList<String>());
    }

    public void test1007(View view){
        RxBus.get().send(1007);
    }
    public void test1007String(View view){
        RxBus.get().send(1007,"字符串数据");
    }
    public void test1007Int(View view){
        RxBus.get().send(1007,1303);
    }
    public void test1007Object(View view){
        RxBus.get().send(1007, new ArrayList<String>());
    }


    @Subscribe(code = 1005,
            threadMode = ThreadMode.MAIN)
    public void receive1005(){
        Log.i("rxbus_log","code  1005 ");
    }

    @Subscribe(code = 1005,
    threadMode = ThreadMode.CURRENT_THREAD)
    public void receive1005(String msg){
        Log.i("rxbus_log","code  1005  String:"+msg);
    }
    @Subscribe(code = 1005)
    public void receive1005(Integer msg){
        Log.i("rxbus_log","code  1005  int:"+msg);
    }
    @Subscribe(code = 1005)
    public void receive1005(ArrayList msg){
        Log.i("rxbus_log","code  1005  data:"+msg);
    }

    @Subscribe(code = 1007)
    public void receive1007(){
        Log.i("rxbus_log","code  1007 ");
    }

    @Subscribe(code = 1007)
    public void receive1007(String msg){
        Log.i("rxbus_log","code  1007  String:"+msg);
    }
    @Subscribe(code = 1007)
    public void receive1007(Integer msg){
        Log.i("rxbus_log","code  1007  int:"+msg);
    }
    @Subscribe(code = 1007)
    public void receive1007(ArrayList msg){
        Log.i("rxbus_log","code  1007  data:"+msg);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        RxBus.get().unRegister(this);
    }
}

rxbus2-1's People

Contributors

xiaoqiwen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.