RxBus


Source link: https://github.com/AndroidKnife/RxBus

RxBus - An event bus by ReactiveX/RxJava/ ReactiveX/RxAndroid

This is an event bus designed to allowing your application to communicate efficiently.

I have use it in many projects, and now i think maybe someone would like it, so i publish it.

RxBus support annotations(@produce/@subscribe), and it can provide you to produce/subscribe on other thread like MAIN_THREAD, NEW_THREAD, IO, COMPUTATION, TRAMPOLINE, IMMEDIATE, even the EXECUTOR and HANDLER thread, more in EventThread.

Also RxBus provide the event tag to define the event. The method's first (and only) parameter and tag defines the event type.

Thanks to:

square/otto

greenrobot/EventBus

Usage

Just 2 Steps:

STEP 1

Add dependency to your gradle file:

compile 'com.hwangjr.rxbus:rxbus:1.0.6'

Or maven:

<dependency>
<groupId>com.hwangjr.rxbus</groupId>
<artifactId>rxbus</artifactId>
<version>1.0.6</version>
<type>aar</type> </dependency>

TIP: Maybe you also use the JakeWharton/timber to log your message, you may need to exclude the timber (from version 1.0.4, timber dependency update from AndroidKnife/Utils/timber to JakeWharton):

compile ('com.hwangjr.rxbus:rxbus:1.0.6') {

  exclude group: 'com.jakewharton.timber', module: 'timber' 
}

en Snapshots of the development version are available in Sonatype's snapshots repository.

STEP 2

Just use the provided(Any Thread Enforce):

com.hwangjr.rxbus.RxBus

Or make RxBus instance is a better choice:

public static final class RxBus {

  private static Bus sBus;

 public static synchronized Bus get() {

if (sBus == null) {

 sBus = new Bus();

}

return sBus;
  
}
 
}

Add the code where you want to produce/subscribe events, and register and unregister the class.

public class MainActivity extends AppCompatActivity {

  ...

 @Override
  protected void onCreate(Bundle savedInstanceState) {

...

RxBus.get().register(this);

...
  
}

 @Override
  protected void onDestroy() {

...

RxBus.get().unregister(this);

...
  
}

  @Subscribe
  public void eat(String food) {

// purpose
  
}

  @Subscribe(

thread = EventThread.IO,

tags = {

 @Tag(BusAction.EAT_MORE)

}

  )
  public void eatMore(List<String> foods) {

// purpose
  
}

 @Produce
  public String produceFood() {

return "This is bread!";
  
}

 @Produce(

thread = EventThread.IO,

tags = {

 @Tag(BusAction.EAT_MORE)

}

  )
  public List<String> produceMoreFood() {

return Arrays.asList("This is breads!");

  
}

 public void post() {

RxBus.get().post(this);

  
}

 public void postByTag() {

RxBus.get().post(Constants.EventType.TAG_STORY, this);

  
}

  ... 
}

That is all done!

Lint

Features

  • JUnit test
  • Docs

History

Here is the CHANGELOG.

FAQ

Q: How to do pull requests?
A: Ensure good code quality and consistent formatting.

License

Copyright 2015 HwangJR, Inc.  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Android Ruler number picker.

Customisable menu that could have from 1 to 10 (and more) buttons. Colors, radius, pictograms - everything can be changed. It suits more for center oriented interfaces and screens. For example by tapping on profile avatar you can open additional functions like Edit, Change Photo etc.

This is a more modified version of EditText. in conventional EditText in android we get the default functionalities, but one of the most important functionality is missing in the default EditText. As we know, we must have to validate the data before taking it as an input in EditText, so this functionality is provided in this mod.

ReactiveFB provides an API that bridges the reactive world of RxJava 2.0 with the callback-style of Facebook-SDK. The aim of the library is to :

  • make the use of the facebook api easy and less boilerplate.
  • expose the facebook api methods to the possibilities of the reactive world like transformations, filtering, composition.

Material Animations practice.

ActivitySwitcher is based on the Activity view operation management library, you can achieve any jump between Activity, close any Activity and end applications and other functions.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes