i'm having the exact same problem.
How does lazy instantiation works with jin?
Can I inject a parametrized type to a class using jin?
I tried several approaches but I get error
Sorry for answering a question in the comments but....
@arashbi Lazy instantiation works fine. You can see this by adding some
sort of message, such as Window.alert("XXX"), to the constructor of a class
created by gin. You will see that the message only appears when the
injector.xxx() method is called. By printing out hashCodes you can also
check that Singleton etc. works as you expect.
For parameterized types use the TypeLiteral class, take a look at the Guice
documentation for this.
While working on a gin module in development mode, I often get
the "Deferred binding result type 'A' should not be abstract" error. After
restarting the development console, it's gone. Just a hint in case you run
into this one as well.
I have a question to Gin team:
In Guice, I specify the module when I am creating an injector. This is fine
because I can create two injectors with different modules, for testing
In Gin, I must specify the module to use in the Injector interface via
@GinModules. So I cannot create two instances of the injector with
different modules. This creates a dependency from an interface to the
implementation and defeats the whole purpose of dependency injection.
Is there a way around it?
There are two ways to reuse Ginjectors. The classic way is to subclass
them, i.e. if the ginjector with all your methods is A, then have 2 (n)
ginjectors B and C, each of which extend A but which define different gin
Another way to easily swap the gin module names is to use GWT properties,
which was recently implemented. Take a look at
for some more documentation.