what is the difference between provider and AsyncProvider in GWT. My understanding is that both are used for code splitting and delayed instantiation. so I am not able to decide, in which case we go for Provider and not for AsyncProvider ?
Thanks in advance!
Provider
is about:
Lazy
type for this very use case.get()
will give you a new object each timeProvider
, otherwise you'll get injected an object from the current request scope, which won't be usable for the next request. GIN only supports the Singleton
scope os it doesn't really apply here, as it's then just a variation of the above factory use case; but on the server-side (with Guice, Spring DI, Dagger, etc.), where servlets or RequestFactory services/locators are singletons (or pseudo-singletons for RF) this is a key part of the DI framework.AsyncProvider
is the same except it's asynchronous, wrapping a call to GWT.runAsync()
.
In other words: only AsyncProvider
is really about code splitting. Provider
will have an impact on the code splitting output but no different than any factory (hand-coded, or GIN's AssistedInject).