ekuefler / gwt-supereventbus Goto Github PK
View Code? Open in Web Editor NEWHigh-octane event bus for GWT
Home Page: https://ekuefler.github.io/gwt-supereventbus
License: Apache License 2.0
High-octane event bus for GWT
Home Page: https://ekuefler.github.io/gwt-supereventbus
License: Apache License 2.0
When compiling :
EventBus.java Line 255 : only class literals may be used as arguments to gwt.create()
I can still test with debug mode.
Hi,
currently evaluating your EventBus implementation to see if I would prefer it to gwteventbinder and currently I am wondering if there is any reason why you provide a separate exception handling mechanism for the event bus?
You could have also used GWT's UmbrellaException to record exceptions occurred during event processing and then post that single UmbrellaException to GWT.getUncaughtExceptionHandler() if that handler has been set. During DevMode that handler is automatically set and logs to console.
Personally I believe that an event should never cause any exception and if it does it is totally unexpected. Well and for all unexpected exceptions I have an UncaughtExceptionHandler in place anyways that, when in production mode, sends them to the server along with additional information that help reproduce/debug the issue afterwards.
I can only hardly see any benefit in adding exception handlers to the event bus and in turn being forced to write more code just to be able to redirect these exceptions to the app's UncaughtExceptionHandler.
So any reason why the EventBus should have its own exception handling mechanism?
I don't think it's a SuperEventBus bug, rather an overlay limitation but it should be at least documented.
Overlays are viewed only as JavaScriptObject and never as defined subtypes, causing all posted JSO subtypes events to be sent to all JSO subtypes subscribers.
Could you add the latest version to maven?
I wanted to try this super EventBus which looks really great but I came across a compilation error at the very beginning.
I simply inherited from com.ekuefler.supereventbus.SuperEventBus and followed the guide to post an event between two classes, nice to use!
The problem is event is never send, obviously because EventRegistrationGenerator and EventRegistrationWriter don't compile. Compiler seems to complain about almost every classes they use.
Did I forget to inherit a module?
I'm using eclipse with GPE, GWT 2.5.1 and GAE 1.8.1.1.
Compiling...
Compilation completed in 0,00 seconds
Added 2719 units to cache since last cleanup.
Validating units:
Errors in 'com/ekuefler/supereventbus/rebind/EventRegistrationGenerator.java'
Line 40: No source code is available for type com.google.gwt.core.ext.Generator; did you forget to inherit a required module?
Line 43: No source code is available for type com.google.gwt.core.ext.TreeLogger; did you forget to inherit a required module?
Line 43: No source code is available for type com.google.gwt.core.ext.GeneratorContext; did you forget to inherit a required module?
Line 44: No source code is available for type com.google.gwt.core.ext.UnableToCompleteException; did you forget to inherit a required module?
Line 46: No source code is available for type com.google.gwt.core.ext.typeinfo.JClassType; did you forget to inherit a required module?
Line 48: No source code is available for type com.google.gwt.user.rebind.SourceWriter; did you forget to inherit a required module?
Line 58: No source code is available for type com.google.gwt.core.ext.typeinfo.NotFoundException; did you forget to inherit a required module?
Line 59: No source code is available for type com.google.gwt.core.ext.TreeLogger.Type; did you forget to inherit a required module?
Line 64: No source code is available for type com.google.gwt.core.ext.typeinfo.TypeOracle; did you forget to inherit a required module?
Line 73: No source code is available for type com.google.gwt.user.rebind.ClassSourceFileComposerFactory; did you forget to inherit a required module?
Line 77: The method getCanonicalName() is undefined for the type Class<EventHandlerMethod>
Line 78: The method getCanonicalName() is undefined for the type Class<LinkedList>
Line 79: The method getCanonicalName() is undefined for the type Class<List>
Line 80: The method getCanonicalName() is undefined for the type Class<MultiEvent>
Line 82: No source code is available for type java.io.PrintWriter; did you forget to inherit a required module?
Errors in 'com/ekuefler/supereventbus/rebind/EventRegistrationWriter.java'
Line 44: No source code is available for type com.google.gwt.core.ext.TreeLogger; did you forget to inherit a required module?
Line 53: No source code is available for type com.google.gwt.core.ext.typeinfo.JClassType; did you forget to inherit a required module?
Line 53: No source code is available for type com.google.gwt.user.rebind.SourceWriter; did you forget to inherit a required module?
Line 53: No source code is available for type com.google.gwt.core.ext.UnableToCompleteException; did you forget to inherit a required module?
Line 60: The method format(String, String) is undefined for the type String
Line 63: No source code is available for type com.google.gwt.core.ext.typeinfo.JMethod; did you forget to inherit a required module?
Line 74: The method getCanonicalName() is undefined for the type Class<MultiEvent>
Line 77: The method getCanonicalName() is undefined for the type Class<capture#1-of ?>
Line 91: The method format(String, String) is undefined for the type String
Line 127: No source code is available for type com.google.gwt.core.ext.TreeLogger.Type; did you forget to inherit a required module?
Line 128: The method format(String, String, String) is undefined for the type String
Line 133: The method format(String, String, String) is undefined for the type String
Line 139: The method getCanonicalName() is undefined for the type Class<MultiEvent>
Line 143: The method format(String, String, String) is undefined for the type String
Line 152: The method isAssignableFrom(Class<capture#5-of ?>) is undefined for the type Class<capture#4-of ?>
Line 155: The method getSimpleName() is undefined for the type Class<capture#6-of ?>
Line 155: The method getSimpleName() is undefined for the type Class<capture#7-of ?>
Line 164: The method format(String, String, String) is undefined for the type String
Line 182: The method getSimpleName() is undefined for the type Class<capture#9-of ?>
Line 190: The method getCanonicalName() is undefined for the type Class<capture#10-of ?>
Line 198: No source code is available for type com.google.gwt.core.ext.typeinfo.JType; did you forget to inherit a required module?
Line 200: No source code is available for type com.google.gwt.core.ext.typeinfo.JPrimitiveType; did you forget to inherit a required module?
Line 225: No source code is available for type java.lang.reflect.Constructor<T>; did you forget to inherit a required module?
Line 225: The method getConstructors() is undefined for the type Class<capture#11-of ?>
Line 231: No source code is available for type java.lang.SecurityException; did you forget to inherit a required module?
Removing invalidated units
Since GWT code generation will most likely be nuked with GWT 3.0, are there any plans to migrate the code generation part to annotation processors?
we need to do
interface MyRegistration extends EventRegistration {}
and
eventBus.register(this, (MyRegistration) GWT.create(MyRegistration.class));
before using the @subscribe. That is boilerplate code like in gwteventbinder the Event need to extend GenericEvent.
I am also using guava EventBus with Spring in server side which let spring auto register
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
@Component
public class EventBusPostProcessor implements BeanPostProcessor
{
@Autowired
private EventBus eventBus;
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
{
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
{
// for each method in the bean
Method[] methods = bean.getClass().getMethods();
for (Method method : methods)
{
// check the annotations on that method
Annotation[] annotations = method.getAnnotations();
for (Annotation annotation : annotations)
{
// if it contains the Subscribe annotation
if (annotation.annotationType().equals(Subscribe.class))
{
// register it with the event bus
eventBus.register(bean);
// we only need to register once
return bean;
}
}
}
return bean;
}
}
Do you know any approach to do this ?
for example, with GIN ?
Thank you very much~!
Right now EventRegistration#getMethods only observes subscribed methods in the same class. It would be nice if it walked up the superclass hierarchy and added any annotated methods from ancestor classes as well.
Use case: I have several views that all share the same layout. I want to encapsulate the behavior of the layout (which has some events it should react to) in a superclass, and have the view classes entirely focused.
I decided to create some common views / presenters in a module that I planned to reuse in various projects. I used supereventbus to bind some interactions; in debug mode, I can see that while the events are properly posted, they are never picked up by methods in the parent module that subscribe to them.
The presenters are initialized by gin in the child modules; perhaps that's preventing them from being properly scanned by supereventbus? I can share code with you that demonstrates this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.