Hi,
We have project, that is written in Java and using J2ObjC used in both iOS and Android (as platform independend backend). The idea is to use same Java code in Electron app.
Part of our core architecture is usage of EventBus. We are using it for message broadcasting etc. It depends on reflection and that is not supported in j2cl.
The question is - how do you handle EventBus usage? It is part of Guava and I believe it is used in some Google projects as well.
Thanks!
Jindrich
We don't have internal usages of Guava EventBus with J2CL.
I checked the Guava EventBus and as you pointed EventBus depends on reflection. It also depends on ConcurrentLinkedQueue but it is easy to add an emulation for.
The usual J2CL compatible replacement for reflection is code generation. However that is quite big of a change in the library and I don't think Guava maintainers have such a plan but we can double check.
On the other hand; there is an existing library written for GWT which already mimics Guava EventBus and works with code generation: gwt-supereventbus
That one should be quite straight forward to make J2CL compatible; most of the work is to replace GWT code generator with APT which is easy. I will ping Erik about that.
Realizing that this isn't the same kind of event bus, the EventBus in GWT itself has also been migrated to plain Java and seems to be j2cl compatible: Project is at https://github.com/gwtproject/gwt-events, https://github.com/gwtproject/gwt-events/blob/master/src/main/java/org/gwtproject/event/shared/SimpleEventBus.java
Seems to me the design of Guava's eventbus was justified pre-Java8 method
references. I think you could get away with an annotation processor based
implementation, e.g. generate a class which implements some callback
Handler interface and delegates to the subscribe method, then you'd do
something like
bus.register(new MySubscriber_Handler()) or some such. That would work on
all platforms. However, it will requires a change in Guava itself.
On Wed, Feb 6, 2019 at 7:44 AM Colin Alworth notifications@github.com
wrote:
Realizing that this isn't the same kind of event bus, the EventBus in GWT
itself has also been migrated to plain Java and seems to be j2cl
compatible: Project is at https://github.com/gwtproject/gwt-events,
https://github.com/gwtproject/gwt-events/blob/master/src/main/java/org/gwtproject/event/shared/SimpleEventBus.java—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/j2cl/issues/29#issuecomment-461071157, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIuJjiBGFhUiG5rRUmVJD-931pPEfBZks5vKvhogaJpZM4alMsJ
.