EventBus 3.0学习

EventBus  学习

官方网址:http://greenrobot.org/eventbus/

Github网址:https://github.com/greenrobot/EventBus

介绍:

EventBusis an open-source library for Android using thepublisher/subscriberpattern for loose coupling(松耦合). EventBus enables central communication to decoupled classes with just a few lines of code – simplifying the code(简化代码), removing dependencies(解除依赖), and speeding up app development.

Github:Android optimized event bus that simplifies communication betweenActivities,Fragments,Threads,Services,etc. Less code, better quality.


EventBus Benfit:

simplifies the communication between components

decouples(解耦) event senders and receivers

performs well with Activities, Fragments, and background threads

avoids complex and error-prone dependencies and life cycle issues

is fast; specifically optimized(优化) for high performance

is tiny (<50k jar)

isproven in practice by apps with 100,000,000+ installs

has advanced features like delivery threads, subscriber priorities(优先), etc.

Further EventBus Features

Simple yet powerful:EventBus is a tiny library with an API that is super easy to learn. Nevertheless, your software architecture may great benefit by decoupling(解耦) components: Subscribers do not have know about senders, when using events.

Battle tested:EventBus is one of the most used Android libraries: thousands of apps use EventBus including very popular ones. Over a billion app installs speak for themselves.

High Performance:Especially on Android, performance matters(性能问题). EventBus was profiled and optimized(优化) a lot; probably making it the fastest solution of its kind.

Convenient(方便的) Annotation based API:Simply put the @Subscribe annotation to your subscriber methods. Because of a build time indexing of annotations, EventBus does not need to do annotation reflection during your app’s run time.

Android main thread delivery(分发):When interacting with the UI(当和UI交互), EventBus can deliver events in the main thread regardless how an event was posted.

Background thread delivery:If your subscriber does long running tasks, EventBus can also use background threads to avoid UI blocking.

Event & Subscriber inheritance(继承):In EventBus, the object oriented paradigm apply to event and subscriber classes. Let’s say event class A is the superclass of B. Posted events of type B will also be posted to subscribers interested in A. Similarly the inheritance of subscriber classes are considered.

Jump start:You can get started immediately – without the need to configure anything – using a default EventBus instance available from anywhere in your code.

Configurable(可配置):To tweak EventBus to your requirements, you can adjust its behavior using the builder pattern.

EventBus Documentation

链接:http://greenrobot.org/eventbus/documentation/how-to-get-started/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,567评论 5 6
  • 《表达》 有时候院子里的花花草草 比我更懂得表达自己的情感 它们见到你时 在风中情不自禁地点头哈腰 而我只是默默地...
    湖北雪儿阅读 531评论 0 6
  • 我一直在漆黑的下着小雨的夜里行走,妄想看清周围一切,突然有一个人出现,他带来了一束光,让我欣喜雀跃,但是也让明白不...
    叫棉花糖的大灰狼阅读 270评论 0 0
  • 从前,在森林的深处,有个小女孩。 她爸爸不停地打她,她很怕很怕,只好躲到壁炉的炉膛里去,那里漆黑冰凉,但是很安全。...
    足马阅读 1,479评论 18 16