Yes it can be done!
Bind your SomeWidget
class in Singleton:
bind(SomeWidget.class).in(Singleton.class);
so both views will have the same SomeWidget
instance.
If your SomeWidget
is used in UiBinder (like in BarView
), you must annotate your SomeWidget
field with @UiField(provided = true)
:
@UiField(provided = true)
SomeWidget someWidget;
and assign the field in your constructor before the call to initWidget
:
@Inject
public PlayerView(Binder binder, SomeWidget someWidget) {
this.someWidget = someWidget;
initWidget(binder.createAndBindUi(this));
}
You must also do those 2 tricks in FooView
.