event-bus

RxJava as event bus?

孤人 提交于 2019-12-21 07:49:14
问题 I'm start learning RxJava and I like it so far. I have a fragment that communicate with an activity on button click (to replace the current fragment with a new fragment). Google recommends interface for fragments to communicate up to the activity but it's too verbose, I tried to use broadcast receiver which works generally but it had drawbacks. Since I'm learning RxJava I wonder if it's a good option to communicate from fragments to activities (or fragment to fragment)?. If so, whats the best

Is Eventbus a Mediator or Observer Pattern?

天涯浪子 提交于 2019-12-21 03:34:13
问题 Is Eventbus more a Mediator or an Observer? According to Google, "eventbus mediator" gets 2.430 hits and "eventbus observer" gets 3.850 hits. From the description, they would both match what I was trying to do (the mediator even a little more). So does eventbus implement a specific pattern or is it up to me which I say it is? 回答1: Often, a given piece of code isn't intrinsically an example of one pattern or another. This is why they're called "patterns" (rather than, say, "implementation

Fragment Callbacks vs EventBus in Android

好久不见. 提交于 2019-12-19 10:26:16
问题 I have faced with the problem. My Activity is fragment container, so to communicate between activity and fragments I used common Callback approach. In this case my activity has to implement tons of callback interfaces depending on fragment count. I don't like to hardcode and unreadable code. In my case my class declaration can take several lines to list all interfaces. I am trying to get rid of this. There is another approach is to use EventBus pattern. In activity EventBus.getDefault()

Event Bus Fragment Unregister

烈酒焚心 提交于 2019-12-18 11:59:40
问题 I've a splashscreen Fragment that is registered to event bus: @Override public void onStart() { super.onStart(); EventBus.getDefault().register(this); } @Override public void onStop() { EventBus.getDefault().unregister(this); super.onStop(); } If the screen goes autolock (or any other event that could call onStop), the container activity goes onStop and the fragment is no more capable to receive the (network) event. I'm thinking about moving "unregister" logic to onDestroy method. Is it a

Android Pros & Cons: Event Bus and RxJava

不打扰是莪最后的温柔 提交于 2019-12-18 11:40:09
问题 I have been using Event Bus in my apps (i.e: greenrobot/EventBus). But I find some disadvantages in using Event Bus: Chaining tasks execution is difficult A lot of classes to represent events Less clear code (well, it's still possible to trace, but not as clear) I have been researching for new techniques to deal with this problem. And I read quite a bit about RxJava and wonder if it could be a solution. So my questions about RxJava (based on what I have read recently): Could RxJava observer

EventBus on Android: how to implement dynamic queues vs. class-based event subscription?

强颜欢笑 提交于 2019-12-12 19:15:43
问题 I want to use EventBus (by Greenrobot, or any other) for the communication between the components of my Android application. In all the example, the pub/sub was implemented using a "class" as a "topic", i.e. each subscriber declares the exact class of events it should receive. I wonder if there is a more dynamic mechanism. Here is what I need to accomplish: my app needs to send commands (say, "Hello!") to multiple systems: 1, 2, ... N. The structure of the command is the same for all of them.

Is event bus library mechanism as bad as the use of static variables to pass data between activities?

a 夏天 提交于 2019-12-12 17:05:39
问题 I'm learning Android, and AFAIK, the standard Android mechanism to pass data between Activities is using Intents which in turn are implemented as IPC on lower level (maybe I'm wrong). It seems that recently have emerged a bunch of libraries to make life easier to Android devs. Between them, the famous Event Bus (Greenrobot's one, Square's Otto). I've been trying both (almost exact interface semantics) and have seen some posts around on how to use Greenrobot event bus to post events to an

React.js - flux vs global event bus

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 07:49:23
问题 What is the advantage of using Flux over a global event bus? I think the dispatcher is all that is needed: component publishes 'user event' with data to the dispatcher dispatcher executes handler of the subscribed store handler publishes 'update event' with the store's updated properties dispatcher executes handler of the subscribed component, and updates component state with the store's updated properties What am I missing here that I can't do without Flux? 回答1: I think what others have said

How to use eventbus messaging in vertx?

怎甘沉沦 提交于 2019-12-11 16:19:33
问题 I followed the instructions in sample and ran: vertx run eventbus_pointtopoint/receiver.rb -cluster vertx run eventbus_pointtopoint/sender.rb -cluster Then I only got: ➜ ruby vertx run eventbus_pointtopoint/receiver.rb -cluster Starting clustering... No cluster-host specified so using address 192.168.56.1 Succeeded in deploying verticle ➜ ruby vertx run eventbus_pointtopoint/sender.rb -cluster Starting clustering... No cluster-host specified so using address 192.168.56.1 Succeeded in

Guava EventBus delaying handler execution of nested events

久未见 提交于 2019-12-11 10:46:21
问题 My issue is pretty identical to Guava EventBus dispatching, but while the underlying issue is similar, my attempted fix has left me in the dark. I have 2 events that are fired back to back. The 2nd event is dependant on the final state of the first event after all handlers are done with it. It should only fire if the 1st event wasn't cancelled. The catch is that both of these events are fired from within another event's handler. So while I don't care who listens to the 1st nested event, I do