Reputation: 57
I have an interface (CssResource) that 'instantiates' itself by: MyInterface singleton = GWT.create(MyInterface.class).
When i try to use it, let's say in MyClass2, i just call it by: MyInterface myClass = MyInterface.singleton;
Then if i do the same in MyClass3, am i calling the same instance as MyClass1 or just creating a new instance?
If the latter is the case, is there a way to call the same?
Upvotes: 0
Views: 90
Reputation: 1607
Declare your INSTANCE as static and final inside your ClientBundle interface in that way:
public interface MyResources extends ClientBundle {
public static final MyResources INSTANCE = GWT.create(MyResources.class);
@Source("my.css")
public CssResource css();
}
Access your instance like MyResources.INSTANCE, it would not be instantiated twice.
https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle
Upvotes: 1