What is the difference between Provider<T> and Lazy<T>?

1,885 views
Skip to first unread message

confile

unread,
Jul 19, 2015, 6:29:19 AM7/19/15
to dagger-...@googlegroups.com
What is the difference between Provider<T> and Lazy<T>?

I know that Lazy<T> retrieves alway the same type. But when T is bound in Dagger2 as @Singleton then I assume it is the same as Lazy?



Gregory Kick

unread,
Jul 19, 2015, 7:48:39 PM7/19/15
to dagger-...@googlegroups.com
On Sun, Jul 19, 2015 at 5:29 AM confile <michael....@googlemail.com> wrote:
What is the difference between Provider<T> and Lazy<T>?

http://google.github.io/dagger/api/2.0/dagger/Lazy.html explains that all in detail with examples. 
 

I know that Lazy<T> retrieves alway the same type. But when T is bound in Dagger2 as @Singleton then I assume it is the same as Lazy?


You are correct that calls to Lazy.get() for something bound as a singleton will return the same instance even for different lazy instances.
 


--
You received this message because you are subscribed to the Google Groups "Dagger Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dagger-discus...@googlegroups.com.
To post to this group, send email to dagger-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages