奥托VS LocalBroadcast: [英] Otto vs LocalBroadcast:
问题描述
我的开源贡献方已尽到Android社区的超级粉丝,并寻找到了他们的最新贡献奥托(事件总线)
挖较深我看到,奥托使用反射和有否有序广播(其中一个未消耗的消息传下来从一个接收机到下一接收器listeneing上的相同类型的事件的图案)奥托相信更火灾和忘记模式。
现在Android已经LocalBroadcastManager(LBM)在其中有异曲同工之妙V4支持库,但其更笨重,而且对所传递的对象更多的限制。但在光明的一面它支持有序广播和其更接近于正常播放。
无论奥托和LBM是相同的进程空间中,以便在速度方面我想这两个是一样的。唯一真正的区别,我可以看到的是,奥托允许您定义自定义事件,你不必序列化/包裹的对象。
因此,当您将使用奥托如果LBM做同样的事情,我真正的问题是。
参考文献:
<一个href="http://nick.perfectedz.com/otto-event-system/">http://nick.perfectedz.com/otto-event-system/
<一个href="http://stackoverflow.com/questions/17317922/using-intents-or-an-event-bus-to-communicate-within-the-same-app">Using意图或事件总线在同一应用内通信
<一个href="https://plus.google.com/107049228697365395345/posts/6j4ANWngCUY">https://plus.google.com/107049228697365395345/posts/6j4ANWngCUY
但在光明的一面它不支持有序广播
不是真的。没有 sendOrderedBroadcast()
在 LocalBroadcastManager
,而在的IntentFilter $的优先级C $ C>似乎没有被使用。如果你的意思是该节目将交付我注册的接收器的秩序,这可能是目前的行为,但也不能保证它会保持下去。
无论奥托和LBM是相同的进程空间中,以便在速度方面我想这两个是一样的。
它们有异曲同工之处,虽然可能不相同。
因此,当您将使用奥托如果LBM做同样的事情,我真正的问题是
比较这两个,奥托有一个更简洁的API,恕我直言。
就个人而言,我会使用 greenrobot的EventBus 通过任那些,因为它提供了更灵活的线程模型。
I am a huge fan of open source contributions square has done to the Android community and was looking into their latest contribution Otto (event bus )
Digging deeper i see that Otto uses reflection and there is No ordered broadcast ( a pattern where a unconsumed message is handed down from one receiver to the next receiver listeneing on the same type of event ) Otto believes in more of a fire and forget model .
Now android has LocalBroadcastManager (LBM ) in its v4 support library which serves the same purpose , though its more bulkier and has more restrictions on the objects that are passed . But on the brighter side it does support ordered broadcast and its more akin to the normal broadcast.
Both Otto and LBM are within the same process space so in terms of speed i guess both would be same . The only real difference I could see is that Otto allows you to define Custom Events and you do not have to serialize/Parcel the Objects .
Hence my real question is when would you use Otto if LBM does the same things .
References :
http://nick.perfectedz.com/otto-event-system/
Using Intents or an event bus to communicate within the same app
https://plus.google.com/107049228697365395345/posts/6j4ANWngCUY
But on the brighter side it does support ordered broadcast
Not really. There is no sendOrderedBroadcast()
on LocalBroadcastManager
, and the priority on the IntentFilter
does not appear to be used. If you mean "the broadcasts will be delivered in the order that I registered the receivers", that might be the current behavior, but there is no guarantee that it will stay that way.
Both Otto and LBM are within the same process space so in terms of speed i guess both would be same
They would be similar, though probably not identical.
Hence my real question is when would you use Otto if LBM does the same things
Comparing those two, Otto has a cleaner API, IMHO.
Personally, I'd use greenrobot's EventBus over either of those, because it offers more flexible threading models.
这篇关于奥托VS LocalBroadcast:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!