A future-proof port of the com.google.web.bindery.event.Event GWT module,
with no dependency on gwt-user (besides the Java Runtime Emulation),
to prepare for GWT 3 / J2Cl.
Also features a port of com.google.gwt.event.logical.LogicalEvent,
and compatibility layers, in the form of a partial port of com.google.gwt.event.Event
as well as a bridge between this new library and the gwt-user modules.
All modules can be used on client-side, server-side, or Android.
-
Add the dependency to your build.
For Maven:
<dependency> <groupId>org.gwtproject.event</groupId> <artifactId>gwt-event</artifactId> <version>${gwtEventVersion}</version> </dependency>
For Gradle:
implementation("org.gwtproject.event:gwt-event:${gwtEventVersion}") -
Update your GWT module to use
<inherits name="org.gwtproject.event.Event" />
(either change from
com.google.web.bindery.event.Event, or add it if you inherited it transitively from another GWT module) -
Change your
imports in your Java source files:import org.gwtproject.event.shared.Event; import org.gwtproject.event.shared.EventBus; import org.gwtproject.event.shared.HandlerRegistration;
The org.gwtproject.event.compat.EventCompat module provides a CompatEventBus class
that wraps an org.gwtproject.event.EventBus as a com.google.gwt.event.shared.EventBus.
This can be especially useful to start migrating to org.gwtproject.event.Event
without being blocked by libraries still using com.google.web.bindery.event.Event
or com.google.gwt.event.Event.
-
Add the dependency to your build.
For Maven:
<dependency> <groupId>org.gwtproject.event</groupId> <artifactId>gwt-event-compat</artifactId> <version>${gwtEventVersion}</version> </dependency>
For Gradle:
implementation("org.gwtproject.event:gwt-event-compat:${gwtEventVersion}") -
Update your GWT module to use
<inherits name="org.gwtproject.event.compat.EventCompat" />
-
Wrap an
EventBuswithin aCompatEventBuswhenever you need it; aCompatEventBusis very lightweight, create as many as you need.
While this is mostly equivalent to having two separate event buses,
given that events aren't compatible with each others,
the fact CompatEventBus can wrap any org.gwtproject.event.shared.EventBus
means that, for instance, you only need one CountingEventBus,
and a ResettableEventBus's removeHandler will remove all handlers
added to either the wrapped bus or the CompatEventBus
(and supports any other use-case where you have a specific EventBus).
Internally, CompatEventBus records a mapping between the
com.google.web.bindery.event.shared.Event.Types and (internal)
org.gwtproject.event.shared.Event.Types.
This mapping is shared by all CompatEventBus instances,
meaning that you can wrap your EventBuses as close as where you need it,
and two CompatEventBuses wrapping the same EventBus will
happily dispatch events to each other (through the shared bus they wrap).
-
Add the dependency to your build.
For Maven:
<dependency> <groupId>org.gwtproject.event</groupId> <artifactId>gwt-logical-event</artifactId> <version>${gwtEventVersion}</version> </dependency>
For Gradle:
implementation("org.gwtproject.event:gwt-logical-event:${gwtEventVersion}") -
Update your GWT module to use
<inherits name="org.gwtproject.event.logical.LogicalEvent" />
(either change from
com.google.gwt.event.logical.LogicalEvent, or add it if you inherited it transitively from another GWT module) -
Change your
imports in your Java source files fromcom.google.gwt.event.logical.*toorg.gwtproject.event.logical.*
You should first migrate to com.google.web.bindery.event.Event
then follow the steps above.
However, GwtEvent and EventHandler are provided to make the migration easier
(i.e. so you can first migrate away from gwt-user
and then refactor your code from GwtEvent to Event).
-
Add the dependency to your build.
For Maven:
<dependency> <groupId>org.gwtproject.event</groupId> <artifactId>gwt-event-legacy</artifactId> <version>${gwtEventVersion}</version> </dependency>
For Gradle:
implementation("org.gwtproject.event:gwt-event-legacy:${gwtEventVersion}") -
Update your GWT module to use
<inherits name="org.gwtproject.event.legacy.EventLegacy" />
(either change from
com.google.gwt.event.Event, or add it if you inherited it transitively from another GWT module) -
Change your
imports in your Java source files:import org.gwtproject.event.legacy.shared.EventHandler; import org.gwtproject.event.legacy.shared.GwtEvent;