You shouldn't instantiate activities at "startup", and you shouldn't reuse 
an activity instance. The idea of GWT activities is that they are cheap to 
instantiate (contrary to views, because of DOM manipulations) so you 
instantiate one each time the ActivityManager is asked to provide it.
Using GIN, it means you'd @Inject Provider<?>s (or factories if you want to 
pass arguments, such as Place-specific values: for instance, the ID of the 
object to be edited) for your activities into your ActivityManager (so that 
an activity is instantiated each time you call the Provider's get() method), 
and you won't annotate the activities with @Singleton (but you would bind 
views as singletons, to do the heavy work once only per view).
That way, the first time an activity is needed, its dependencies are 
initialized also (i.e. the view is created / the placeController is already 
initialized so it's provided directly and it's a no-op), and this can be "a 
bit of work" (instantiating the view, which involves "heavyweight" DOM 
manipulations). Next time you need an instance of the same activity type, 
dependencies (which are likely to all be singletons) are already initialized 
and creating the activity is very cheap (you shouldn't do much work in the 
constructor, just store the dependencies in fields so you'll use them later, 
waiting forthe start() method to be called).

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to