-
6 Dec 2012 9:57 AM #1
method ensureHandler() from Loader should be protected
method ensureHandler() from Loader should be protected
I want to extend the standard Loader<C, M> (Loader.java) with some extra handers. Therefore i need acces to;
Or a least;Code:SimpleEventBus ensureHandler() { return eventBus == null ? eventBus = new SimpleEventBus() : eventBus; }
In my opinion method ensureHandler() should be given modifier protected instead of no modifier. This gives subclasses of Loader acces to the eventBus. Of course an extra method;Code:private SimpleEventBus eventBus;
Is even betterCode:public void setEventBus(EventBus pEventBus) { eventBus = pEventBus; }
-
6 Dec 2012 11:15 AM #2
Setting an EventBus is a bit of a no-no, since we might change the underlying event structure - as long as we adhere to the addFooHandler declared in any HasFooHandlers interface, we can keep the actual implementation hidden away and mutable without changing dependent code.
What we are more likely to do is add a protected addHandler(Type, Handler) method, which will itself call ensureHandlers - this lets us decide how to build the handler container (HandlerManager/SimpleEventBus/etc) without making subclasses dependent on the implementation. The fireEvent is already protected in this same way.
Why do you need this? Can you not build a new event router for your specific events? or invoke fireEvent(...) for existing events? Often times when someone subclasses something like this and adds functionality, it isn't meant to be used as the underlying base class any more - be careful that by subclassing you are only adding functionality, and not changing the nature of the underlying class - if you are, you should be composing, not inheriting.
I've filed as an issue, and will update it when we change this API.
You found a bug! We've classified it as
EXTGWT-2672
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote