I've been looking at MVC implementations and Event-bus closely.
Why not use Event-bus instead of Observer Pattern to implement a MVC application?
For example, lets say I have two classes Model
and View
, In typical observer pattern it would be:
public class Model implements Subject { ... }
public class View implements Observer { ... }
Instead, what is the benefit/drawback of an approach using green robot event bus or any other Event-bus?
It would be something like:
public class Model {
private int field = 0;
void someFunctionNowTriggerStateChange() {
this.field = field + 1;
...EventBus.getDefault().post(this); //pass itself as the event
}
}
public class View {
@Subscribe onModelUpdated(Model model) {
updateTextLabel(model);
//other model updates
}
}
What are the issues (if any) of using the EventBus to implement MVC vs typical Observer?