Android Otto 使用

来源:互联网 发布:mac沙盒机制 编辑:程序博客网 时间:2024/06/04 18:56

 最近做的项目用到了Otto,记录一下,

     官方地址:http://square.github.io/otto/

     github地址:https://github.com/square/otto


 android  传统的事件传递,有Handler 、broadcastReceiver,个人觉得broadcastReceiver 最难用。

  

 otto 使用:

         1.otto 使用注解定义订阅和发布的角色,@Subscribe 订阅者(接收),@Produce 发布者(发送消息),这个注解定义到方法名称上即可

         2.otto Bus  这个类没有自己实现单例,需要我们自己实现

         3.otto 订阅和发布都需要注册(register和unregister)

    

0 0