Hey Ray,

Thanks for trying to make GIN user's lives easier when using UiBinder.
However, injecting an injector wouldn't really work. Most GIN
applications will end up having one top level Ginjector that would
have a getter for some top level application widget. When you start
creating multiple Ginjectors, instances of classes don't stay the
same. For example, a Singleton EventBus in two Ginjectors are
different instance types.

Also, I'm pretty sure you can't put an @Inject on an interface method,
but I haven't tried.
--
Arthur Kalmenson



On Mon, Aug 9, 2010 at 10:29 PM, Ray Ryan <rj...@google.com> wrote:
> If you don't use GIN (you know, that really should be GIn), the rest of this
> note probably won't interest you.
> Would something like the following improve life for GIN users enough to be
> worth doing? Or is it just a hack?
>
> public interface UiBinderWithFactory<U, O, F> extends UiBinder<U, O> {
>   /**
>    * Sets a factory to use when instantiating objects that are not
>    * provided via @UiFactory methods or @UiField(provided = true) fields.
>    * <p>
>    * When an instance is needed, a zero args method with an appropriate
> return type
>    * will be sought on the factory to provide it. If none is found
> GWT.create()
>    * will be used instead.
>    * <p>
>    * It is a compile time error for the factory to provide ambiguous
> methods.
>    */
>   setFactory(F factory);
> }
>
> You might wind up with code like…
>
> @Inject
> public MyWidget(MyUiBinder binder) extends Composite {
>
>   public interface MyUiBinder extends UiBinderWithFactory<Widget, MyWidget,
> MyGinjector> {
>    �...@inject setfactory(MyGinjector factory);
> }
>
> …and a few extra getters on your Ginjector.
>
> Now injecting an injector is generally a terrible idea, but it's something
> at least. (Does that even work in Gin? And can you put @Inject on an
> interface method?)
> What do you think?
> rjrjr
>
> --
> http://groups.google.com/group/Google-Web-Toolkit-Contributors

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to