V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
jeremyliao
V2EX  ›  Android

第一个上 k 的 GitHub 项目「LiveEventBus」

  •  
  •   jeremyliao · Jul 9, 2019 · 13925 views
    This topic created in 2490 days ago, the information mentioned may be changed or developed.
    「 LiveEventBus 」 https://github.com/JeremyLiao/LiveEventBus

    非常好用的消息总线框架
    4 replies    2019-07-31 11:22:05 +08:00
    songdehuai
        1
    songdehuai  
       Jul 10, 2019
    已 star,学习一下
    jeremyliao
        2
    jeremyliao  
    OP
       Jul 10, 2019
    snoppy
        3
    snoppy  
       Jul 11, 2019
    学习, 已 star
    loopq
        4
    loopq  
       Jul 31, 2019
    来挖坟,学习一下还可以,毕竟使用了最新的技术。不过实际项目中可能不会使用,说一下我的看法,希望不会冒犯
    1.发送事件和接收事件都需要相同的一个 Key,这样项目中会需要一个文件来维护这个 Key
    2.接收事件的是这么用的。
    LiveEventBus.get()
    .with(KEY_TEST_CLOSE_ALL_PAGE, Boolean.class)
    .observe(this, new Observer<Boolean>() {
    @Override
    public void onChanged(@Nullable Boolean b) {
    if (b) {
    finish();
    }
    }
    });
    我们项目中一个 event processor 可能会有 20 个 event,用你的这个写法第一个不够清晰,第二个代码感觉太冗余了。

    顺便:我们项目中用的是 greenboot 家的 eventbus
    整个发送流程是这样的
    /**
    * event 实体
    */
    public class ShowLandingEvent{
    ...
    }

    // 发送事件
    BusProvider.post(new ShowLandingEvent(...) )

    // 接收事件
    public void ShowLandingEvent(ShowLandingEvent event){
    ....
    }

    个人感觉,会比你的清晰很多。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2079 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 16:11 · PVG 00:11 · LAX 09:11 · JFK 12:11
    ♥ Do have faith in what you're doing.