Re: How to bind essential singletons in multi-module GIN app and avoid duplicate binding

2016-10-29 Thread Ignacio Baca Moreno-Torres
I think that you are describing the GWTP DefaultModule
https://github.com/ArcBees/GWTP/blob/master/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/gin/DefaultModule.java
 

On Thu, Oct 27, 2016 at 7:48 AM Thomas Broyer  wrote:

> I don't know if it's supported by GIN but Guice has a requireBinding to
> prevent the second case. And if the user of your lib has to use GIN it's
> not abnormal to ask them to bind a few things. You can provide GinModules
> that bind them if you like so they only have to compose them in their
> Ginjector without the need to write the bindings themselves.
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-web-toolkit+unsubscr...@googlegroups.com.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> Visit this group at https://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: How to bind essential singletons in multi-module GIN app and avoid duplicate binding

2016-10-26 Thread Thomas Broyer
I don't know if it's supported by GIN but Guice has a requireBinding to prevent 
the second case. And if the user of your lib has to use GIN it's not abnormal 
to ask them to bind a few things. You can provide GinModules that bind them if 
you like so they only have to compose them in their Ginjector without the need 
to write the bindings themselves.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: How to bind essential singletons in multi-module GIN app and avoid duplicate binding

2016-10-26 Thread vitrums
Yes indeed, I don't provide an entry point for my lib-like module. However, 
there're handfull of other singletons one might have a necessity to have an 
access to (EventBus was just an example). E.g. 
com.google.gwt.core.client.Scheduler. Prior to GIN we had a sole option to 
obtain an instance by calling Scheduler.get(). Now I try to avoid mixing 
*GWT.create(), 
other static factories* and *@Inject *within client's code and therefore 
*prefer 
injection *anywhere possible. But here comes the same problem. Suppose, I 
*injected* the scheduler in some class within my lib-like module and 
intentionally left no binding within my lib config module. Now the client 
of my lib-like module either starts to get *"no binding found"* exceptions, 
or even worse - silently execute with new scheduler instances injected 
every time (if e.g. there was a default constructor for Scheduler).

On Wednesday, October 26, 2016 at 9:28:34 PM UTC+3, Jens wrote:
>
> Sounds like your visual components act as libraries, thus not having their 
> own GWT entry point.
>
> IMHO your visual components should not provide bindings for classes they 
> do not own. That means app wide singletons like an EventBus must be 
> provided by the app that includes the visual component.
>
> -- J.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: How to bind essential singletons in multi-module GIN app and avoid duplicate binding

2016-10-26 Thread Jens
Sounds like your visual components act as libraries, thus not having their 
own GWT entry point.

IMHO your visual components should not provide bindings for classes they do 
not own. That means app wide singletons like an EventBus must be provided 
by the app that includes the visual component.

-- J.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


How to bind essential singletons in multi-module GIN app and avoid duplicate binding

2016-10-26 Thread vitrums
[ Original post on 
StackOverflow 
http://stackoverflow.com/questions/40132219/how-to-bind-essential-singletons-in-multi-module-gin-app-and-avoid-duplicate-bin
 
]

It's a simple selfdescriptive question (subj).

Anyway, just to give an example. We have a main app module and some visual 
components module (some reusable module for many apps), both constructed 
with GIN. Needless to say, that such instances as *EventBus*, *Scheduler* etc. 
are usually bound as singletons and they get injected here and there. So, 
if we consider the aforementioned visual components module as a somewhat 
independent instance, which requires minimum work on a part of a client to 
get it inherited, then it should contain its own GIN configuration module, 
where it binds those singletons - same the main app configuration module 
usually has. And the compiler obviously won't let duplicates to coexist.

What's the best practice to avoid such a duplication conflict.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.