Home

Awesome

This project is @deprecated in favor of RxJava. It offers the same event-driven programming model as TinyBus, but it's more capable and offers better control of threading.


tinybus

TinyBus is the faster implementation of Otto event bus with additional features you missed.

Build Status

TinyBus is

TinyBus API in a nutshell

For a more detailed example check out Getting started step-by-step guide or example application.

Performance reference tests

tinybus

Executed on Nexus 5 device (Android 5.0.1, ART, screen off).

TinyBus extensions (still in 'β')

Extensions is a unique feature of TinyBus. With it you can easily subscribe to commonly used events like battery level, connectivity change, phone shake event or even standard Android broadcast Intents. Here is a short example.

public class MainActivity extends Activity {
    private TinyBus mBus;
        
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // get bus instance 
        mBus = TinyBus.from(this)
        
        if (savedInstanceState == null) {
            // Note: ShakeEventWire stays wired when activity is re-created
            //       on configuration change. That's why we register is 
            //       only once inside if-statement.

            // wire device shake event provider
            mBus.wire(new ShakeEventWire());
        }
    }
    
    @Override
    protected void onStart() {
        super.onStart();
	    mBus.register(this);
	}
	
    @Override
    protected void onStop() {
        mBus.unregister(this);
        super.onStop();
    }
    
    @Subscribe
    public void onShakeEvent(ShakeEvent event) {
        // device has been shaken
    }
}

More detailed usage example can be found in example application.

Gradle dependencies

For pure event bus implementation

dependencies {
    compile 'de.halfbit:tinybus:3.0.2'
}

For event bus with extensions

dependencies {
    compile 'de.halfbit:tinybus:3.0.2'
    compile 'de.halfbit:tinybus-extensions:3.0.2'
}

ProGuard configuration

If you use Gradle build, then you don't need to configure anything, because it will use proper configuration already delivered with Android library archive. Otherwise you can use the configuration below:

-keepclassmembers, allowobfuscation class ** {
    @de.halfbit.tinybus.Subscribe public *;
    @de.halfbit.tinybus.Produce public *;
}

Used by

License

Copyright (c) 2014-2015 Sergej Shafarenka, halfbit.de
Copyright (C) 2012 Square, Inc.
Copyright (C) 2007 The Guava Authors

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.