Closed GoogleCodeExporter closed 9 years ago
>>The would allow me to build a framework that other people could build upon
I think this part can be accomplished by using presenter's name:
public interface OneEventBus ... {
@Event(handlerNames={"presenter1"})
void fireSomeEvent(String variable);
}
@Presenter(name="presenter1")
public class OnePresenter ... {}
This can also be another way of doing it:
http://groups.google.com/group/mvp4g/msg/015302b7be763a0e
Original comment by plcoir...@gmail.com
on 28 Sep 2010 at 9:20
The main thing that I am looking for is to be able to annotate/add an interface
to a presenter and then everything that implements that interface has that
annotation will then handle the event.
interface Blah extends EventBus{
@Event(annotatedWith={SomeAnnotation.class})
void someEvent(String something);
}
@Presenter(...)
@SomeAnnotation
public Presenter1 extends BasePresenter<...>
...
public void onSomeEvent(String something){
...
}
@Presenter(...)
@SomeAnnotation
public Presenter2 extends BasePresenter<...>
...
public void onSomeEvent(String something){
...
}
=====================================================================
Or even more preferable would be the following.
@Events(...)
interface FooEventBus extends EventBus{
@Event(implementors = (FooInterface.class})
void someEvent(String something);
}
interface MarkerInterface {}
interface FooInterface extends MarkerInterface{
void onSomeEvent(String something);
}
@Presenter(...)
public Presenter1 extends BasePresenter<...> implements FooInterface{
void onSomeEvent(String something){
}
}
@Presenter(...)
public Presenter2 extends BasePresenter<...> implements FooInterface{
void onSomeEvent(String something){
}
}
Original comment by larse...@gmail.com
on 30 Sep 2010 at 5:14
Maybe an handler auto-detection feature could be added to the event annotation
to automatically add as an handler any presenter that implements the handling
method. You could have something like that:
@Event(autoDetectHandlers=true)
public void event(Object obj1, Object obj2);
Any presenter that define a onEvent(Object obj1, Object obj2) method would be
automatically added as an handler.
Would you like this idea better?
Original comment by plcoir...@gmail.com
on 30 Sep 2010 at 9:16
Now, that would be pretty cool aswell. That seems like it might be more
difficult to implement, and could cause some weird errors if you weren't
careful with your method naming structure, especially if you had something like
@Event(autoDetectHandlers=true)
handleError(Throwable throw);
@Event(autoDetectHandlers=true)
handleError(RuntimeException exception);
This could be troublesome and cause unexpected behavior. I think allowing you
to type it with an interface would make things easier. You could then leverage
a lot of that code for the activate {? extends MarkerInterface}, deactivate {?
extends MarkerInterface} portion aswell.
The other nice thing about using an interface is inside IDEs it becomes easy to
figure out which classes are actually going to handle the event (in eclipse
ctrl+t) on the class and then you know everywhere to look.
Original comment by larse...@gmail.com
on 30 Sep 2010 at 9:34
Mvp4g won't let you have 2 events with the same name (because of the event
lookup functionality). Both solutions probably require the same amount of time
but you get a good point that the interface will allow you to easily find
handlers thanks to eclipse.
How do you think this interface can simplify the code of the
activate/deactivate feature?
I think this feature could be useful if you want to spread events to all
presenters for example. Maybe we could start a survey on this feature on the
forum?
Original comment by plcoir...@gmail.com
on 1 Oct 2010 at 6:25
--Mvp4g won't let you have 2 events with the same name (because of the event
lookup functionality).
My mistake, I'm new to this framework. That's good to know however.
--How do you think this interface can simplify the code of the
activate/deactivate feature?
Basically the same concept for the activate/deactivate feature. Use some kind
of marker interface to indicate all handlers marked that will be
activated/deactivated when the event is fired. It should be easy to re-purpose
most of the code to allow those annotation functions to work the same.
--I think this feature could be useful if you want to spread events to all
presenters for example. Maybe we could start a survey on this feature on the
forum?
Sounds good.
Original comment by larse...@gmail.com
on 1 Oct 2010 at 6:56
Original comment by plcoir...@gmail.com
on 24 Nov 2010 at 12:34
Issue 54 has been merged into this issue.
Original comment by plcoir...@gmail.com
on 6 Dec 2010 at 10:51
This feature is included in the last snapshot. You can check the documentation
here: http://code.google.com/p/mvp4g/wiki/EventBus_130#Broadcast_Event
Original comment by plcoir...@gmail.com
on 9 Dec 2010 at 11:54
Original issue reported on code.google.com by
larse...@gmail.com
on 28 Sep 2010 at 8:06