sergejsha / tinybus Goto Github PK
View Code? Open in Web Editor NEWSimple, lightweight and fast event bus tailored for Android
License: Apache License 2.0
Simple, lightweight and fast event bus tailored for Android
License: Apache License 2.0
Hi,
I've taken over a project at work that use Tinybus events extensively, but I find it hard to keep track of the events and see where they are catched.
I've used Otto before and it has a Android Studio plugin that makes it easy to keep track of the events.
Is there something similar for Tinybus?
If I send multiple consecutive events via .postDelayed(), only the last event is delivered to the subscriber.
Example:
MyEvent eventA = new MyEvent("A");
MyEvent eventB = new MyEvent("B");
mBus.postDelayed(eventA, 1000);
mBus.postDelayed(eventB, 1000);
In the subscriber method I only get 'eventB' delivered.
Hello,
In our app we are seeing this java.lang.RuntimeException once in a while.
Unfortunately, there are nothing in the stack trace which indicates where in our code or when this happens.
Version: de.halfbit:tinybus:3.0.2
java.lang.RuntimeException
de.halfbit.tinybus.TinyBus.handleExceptionOnEventDispatch(SourceFile:329)
de.halfbit.tinybus.TinyBus.processQueue(SourceFile:383)
de.halfbit.tinybus.TinyBus$TinyBusImpl.onPostFromBackground(SourceFile:529)
de.halfbit.tinybus.impl.Task.run(SourceFile:87)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:158)
android.app.ActivityThread.main(ActivityThread.java:7229)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.Method.invoke(Native Method)
de.halfbit.tinybus.TinyBus$TinyBusImpl.dispatchEvent(SourceFile:460)
de.halfbit.tinybus.TinyBus.processQueue(SourceFile:380)
de.halfbit.tinybus.TinyBus$TinyBusImpl.onPostFromBackground(SourceFile:529)
de.halfbit.tinybus.impl.Task.run(SourceFile:87)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:158)
android.app.ActivityThread.main(ActivityThread.java:7229)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
After some recent Play Services update this crash has become very common for any app using any kind of Event Bus implementation on pre-21 devices. Happens when trying to call register(Obj)
.
The only solution I've seen so far is not using anything containing the PersistableBundle
, which I don't use anyway and still have this issue.
Do you have any ideas on that?
when certain parts of the app aren't in the foreground,
can an event be received when it eventually makes its way to the foreground?
thanks for your work!
In the readme, the proguard configuration lists:
-keepclassmembers class ** {
@de.halfbit.tinybus.Subscribe public *;
@de.halfbit.tinybus.Produce public *;
}
Should it not be 'com' instead of 'de':
-keepclassmembers class ** {
@com.halfbit.tinybus.Subscribe public *;
@com.halfbit.tinybus.Produce public *;
}
It would be nice to be able to use private/protected/package methods as @subscribe... Public methods are pollutions.
It would be nice to see both producers: registered and attempted to get registered.
Caused by: java.lang.IllegalArgumentException: Unable to register producer, because another producer is already registered, TopicsLoader{18ee7275 id=-1666337187}
at de.halfbit.tinybus.impl.ObjectsMeta.registerAtProducers(ObjectsMeta.java:231)
at de.halfbit.tinybus.TinyBus.processQueue(TinyBus.java:350)
at de.halfbit.tinybus.TinyBus.post(TinyBus.java:205)
at de.halfbit.tinybus.wires.ConnectivityWire.postEvent(ConnectivityWire.java:169)
at de.halfbit.tinybus.wires.ConnectivityWire$1.onReceive(ConnectivityWire.java:112)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
Any specific reason you are disallowing backup with this library? Right now to include this library and allow backup for an app you have to use tools:replace="android:allowBackup"
in your manifest which is annoying.
Thanks!
Hello!
Would be nice to fail silently or at least to throw an IllegalStateException
?
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void de.halfbit.tinybus.impl.ObjectsMeta.unregisterFromReceivers(java.lang.Object, java.util.HashMap)' on a null object reference
RT,Use TinyBus but can not receive event in another activity, is my code mistake or tinybus do not support for "post to another activity like eventbus"?
When @subscribe or @produce are applied to not public methods, then TinyBus must fail fast.
Does anyone else need it? Why?
Tinybus is only compared to Otto, it would be very interesting to also compare it to greenrobot/Eventbus which seems to fit the same niche.
Hi @beworker,
congratulation for this project and being referenced on Android Weekly.
I looked at your source code and it looks like you are using a lot of reflection to discover the methods that are annotated to subscribe to or produce events (in https://github.com/beworker/tinybus/blob/master/tinybus/src/com/halfbit/tinybus/ObjectMeta.java).
You could actually get some performance gains by using an annotation processor to detect all such methods at compile time and get references to them. Thus you would not need to scan the classes, you would know in advance where such methods are in a given class.
You can find an example of such an annotation processor in :
if you need more high level explanations, please refer to these slides :
https://speakerdeck.com/stephanenicolas/blender-boosting-guice-with-annotation-processing
Can system platform lower than 14 use this lib?
When processQueue throws an exception, the entire event bus stops working (mProcessing remains true)
Suggest adding a try - finnaly block that resets mProcessing
I'm thinking about start using TinyBus in one of my apps, but sadly I still have to maintain compatibility with Gingerbread. Is there any particular reason/feature why you have set minSdkVersion to 14 on the main lib ?
Thanks
Edit: Sorry i didn't read the closed issues and now i know why you use minimum api 14, looks like i will have to stop supporting api <14 users or just use something else :\ .
Hi there i just integrated your awesome library using gradle but it seems your library requires api minimum 14 any particular reason for this?
I ask this because i want to integrate your tiny bus into my app which supports gingerbread devices (API 9)
Happens sporadically on Activity start.
Unexpected error occured at Sunday, 6 September 2015 14:16
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.nakvic.habs/net.nakvic.habs.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'de.halfbit.tinybus.impl.TinyBusDepot$LifecycleCallbacks de.halfbit.tinybus.TinyBus.getLifecycleCallbacks()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'de.halfbit.tinybus.impl.TinyBusDepot$LifecycleCallbacks de.halfbit.tinybus.TinyBus.getLifecycleCallbacks()' on a null object reference
at de.halfbit.tinybus.impl.TinyBusDepot.onActivityCreated(TinyBusDepot.java:124)
at android.app.Application.dispatchActivityCreated(Application.java:189)
at android.app.Activity.onCreate(Activity.java:937)
at android.support.v4.app.BaseFragmentActivityDonut.onCreate(BaseFragmentActivityDonut.java:39)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:242)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:61)
at net.nakvic.habs.BaseActivity.onCreate(BaseActivity.java:51)
at net.nakvic.habs.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
... 10 more
Hi there,
it seems that subclasses won't receive an Event when overriding a superclass method annotated with [at]Subscribe. Could you comment on that? Thanks.
TinyBus.post to @subscribe or onXxxEvent
TinyBus.postDelay to @subscribe or onXxxEvent
@subscribe to TinyBus.post
Tinybus looks really promising but I couldn't find it on Maven Central :). It would be great when we could add this library via a dependency in Gradle to our projects.
Hi, please fix the build script. It stop pull requests from passing the full life cycle
Hi.
I found your library very intersesting and I gave it a try in my custom Views. For now it seems to work, much better than Otto which threw null pointers and sometimes it worked.
I wanted to ask you, can I use it in Long running Tasks, in Services for example, or Broadcast receivers and Volley HTTP call backs.
Thx.
Judging from the results, you are using an outdated EventBus Version. Also please note that you can configure EventBus to disable features tinyBus is not offering to have a fairer comparison: e.g. ignoring hierarchy, no sending of "no-subsriber" events.
I implemented an application context bus. It works from jellybean and higher api levels, However on gingerbread api lvl 10 (2.3.6) when initialising the bus in my application context.
mBus = TinyBus.from(this);
it throws a java.lang.NoClassDefFoundError, Logcat is as below.
01-07 23:07:59.283 1421-1421/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.halfbit.tinybus.TinyBusDepot
at com.halfbit.tinybus.TinyBus.from(TinyBus.java:113)
at com.kenshin.repapp.App.onCreate(App.java:55)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
I checked the source code the manifests states minsdk 14 but the build.gradle states minsdk 10. And so i found out that the problem is that TinyBusDepot uses ActivityLifecycleCallbacks which is only available in api lvl 14 and above. If i am not wrong build.gradle will always override manifests. So i recommend updating the build.gradle file to minsdk 14 and perhaps indicating in the readme the min sdk level for TinyBus.
Consider the following event class:
public final class ParseEvent extends Event {
private User user;
public ParseEvent(User user) {
this.type = Type.ON_USER_PARSE_COMPLETE;
this.user = user;
}
public User user() {
return user;
}
}
Calling post() with an instance of this class does not trigger anything. The User
object is quite large with a lot of fields, could this be the issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.