Git Product home page Git Product logo

modulebus's Introduction

ModuleBus

Module Bus is use for diffent modules communication.

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);

Add ModuleBus to your project

Gradle:

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

Maven:

<dependency>
  <groupId>com.cangwang.core</groupId>
  <artifactId>modulebus</artifactId>
  <version>2.0.0</version>
  <type>pom</type>
</dependency>

*Important
need to set base module depend with ModuleBus and ,other communicated modules depend with base module.

*2016.12.12 update
(1)Use ArrayMap to change with HashMap.
(2)Add startModuleActivity function.
(3)Fix bugs and develop speeds in ModuleBus.

*2017.2.27 update
(1) Add Module architecture inclue activity,fragment and view.
(2) Add Application util ModuleImpl.

*2017.3.3 update moduleBus 2.0.0
(1) update Module architecture inclue activity,fragment and view.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.