通信模块封装同步 ModuleBus

码农软件 · 软件分类 · ESB企业服务总线 · 2020-02-11 21:43:39

软件介绍

ModuleBus

用法上面尽可能靠近 EventBus,大小大概54K没做任何压缩。

已经上传到 JCenter 了,可以直接调用

添加 ModuleBus 到你的项目

Gradle:

compile 'com.cangwang.core:modulebus:1.0.1'

简单介绍一下

需要自己定义一个 Client 用于传输,需要继承于 IBaseClient

然后 ModuleEvent 的 coreClientClass 用于指定对应的 Client,然后添加实现的方法,方法名任意都可以。

然后 register 和 unregister 的方法都和 EventBus 的用法是一样的

post 的方法需要填写第一个参数为 client.class,第二个参数是方法名,之后的参数为方法的参数。

ModuleBus in 3 steps

  1. Define events:

    public static class MessageClient extend IBaseClient { /* Additional fields if needed */ }
  2. Prepare ModuleEvent and function: Declare and annotate your subscribing method.

    @ModuleEvent(coreClientClass = MessageClient.Class)  
    public void fun(Object...args) {/* Do something */};

    Register and unregister your ModuleBus. For example on Android, activities and fragments should usually register according to their life cycle:

    @Override
    public void onStart() {
        super.onStart();
        ModuleBus.getInstance().register(this);
    }
    
    @Override
    public void onDestroy() {
        super.onStop();
        ModuleBus.getInstance().unregister(this);
    }
  3. Post function:

    ModuleBus.getInstance().post(MessageClient.class,"fun",Object...args);

这里需要在 base 的 module 去添加依赖 modulebus ,然后其他需要交互的模块依赖于 base。

例子里面会有简单的演示,只要下载之后就能看到源码和调用了。我也会封装越来越好用得功能到里面。

本文地址:https://www.codercto.com/soft/d/25411.html

重新定义团队:谷歌如何工作

重新定义团队:谷歌如何工作

拉兹洛·博克 / 宋伟 / 中信出版集团 / 2015-12-1 / CNY 56.00

谷歌首席人才官拉斯洛•博克权威力作,谷歌公开认可的谷歌高层作品,首度揭秘谷歌颠覆工业时代模式的人才和团队管理的核心法则,《纽约时报》畅销榜第一名,Business Insider 2015最佳商业书籍,谷歌的创造力就在于此! 编辑推荐! 1、 谷歌人才官首次公开谷歌人才和团队管理的核心秘籍 在谷歌执掌人事多年的拉斯洛•博克是人才和团队管理的顶级专家。他加入谷歌后,谷歌的员工数从六......一起来看看 《重新定义团队:谷歌如何工作》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

html转js在线工具
html转js在线工具

html转js在线工具