用于Android應用的一個輕量級的和簡單的事件總線:tinybus

jopen 10年前發布 | 27K 次閱讀 tinybus Android開發 移動開發

專為Android設計的一個輕量級的和簡單的事件總線。

用于Android應用的一個輕量級的和簡單的事件總線:tinybus

TinyBus is

  • fast (optimized for startup and event dispatching)
  • tiny (~ 17K jar)
  • well tested (> 50 junit tests)
  • annotation based (no requiremens to method names, no interfaces to implement)

Performance comparison tests

用于Android應用的一個輕量級的和簡單的事件總線:tinybus

Executed on Galaxy Nexus device with Android 4.3 (Dalvik) with switched off screen.

TinyBus quick start

// 1. Create event
public class LoadingEvent {
   // some fields if needed
}

// 2. Prepare event subscriber (Activity, Fragment or any other component)
@Subscribe
public void onEvent(LoadingEvent event) {
    // event handler logic
}
bus.register(this);

// 3. post event
bus.post(new LoadingEvent());

For a more detailed example check out Getting started step-by-step guide or example application.

TinyBus 可以幫助

  • 去除不必要的接口和直接組件的依賴
  • 簡化 Activities, Fragments 和 Services之間的通信
  • 簡化后臺線程和主線之間的事件交互
  • 簡化的標準系統事件的消費(like Battery Level, Connection State etc.)

項目主頁:http://www.baiduhome.net/lib/view/home/1416301561367

     本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
     轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
     本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!