0.0.4 (Oct 10, 2016)
Sep 22, 2016
Feb 16, 2017 (Retired)
Janishar Ali (janishar)
AMIT SHEKHAR (amitshekhariitbhu)
Janishar Ali (janishar)
Source code


JPost (Java and Android class communication library)


This library is designed for the communication between classes in java / android by sending and receiving messages. Messages can be any object.

The design of this library is such that the modularity of the code is enhanced and provide a controlled system for sending and receiving messages. One of the key advantages of this library is that the message handling can be done both synchronusly(if the sender thread is same as the receiver thread) or asynchronously as provided. All the subscribing classes are holded with weakreferences, hense the memory leak do not take place. The usecases in which this library's power can be understood is when compared to other pub/sub libraries. Situations in which many instances of a single class require to process messages based on the sender. Example: A class wants to send message to few of the instances of the same class. The schema diagram provided below will provide a better insight.


dependencies {
    compile 'com.mindorks:android-jpost:0.0.4'

Why should you use this library

  1. In contrast to the existing pub-sub libraries, it hold the subscribers with weakreference. Thus it doesn't create memory leaks.
  2. Single message can be sent to selected subscribes. This avoids the problem of event getting received at undesirable places. Thus minimising the chances of abnormal application behaviour.
  3. The subscriber addition can be controlled by using private channels. It minimises the chances of adding subscribes by mistake to receive undesirable messages.
  4. It is a tiny library < 55kb . Thus not effecting the application overall size.
  5. It facilitates synchronous as well as asynchronous message delivery and processing.
  6. It provides a mechanism to run code asynchronously.

Library Classes Overview


The one point entry for this library is the class JPost. It contains static methods to access BroadcastCenter class and core functionality related to the library management.


  1. JPost.getBroadcastCenter(): This method is used to get the instance of BroadcastCenter class (BroadcastCenter is described below)
  2. JPost.shutdown(): This method closes the JPost for the async operations and removes all the pool threads. It should called when the program terminates or as required. This call let the message delivery already in process to continue.
  3. JPost.haltAndShutdown(): This method does the same operation as do the JPost.shutdown() but it also removes all the message delivery tasks.;