Dagger 2: is it possible to customize the lazy creation of default?
In General, I began to study/implement Dagger 2 and made a blunder: did everything according to normal (I understand that they are created from the entire module), and I need that they are all created on demand. Is it possible to configure so Dagger worked by default? And then redo a hundred places have...
Dagger creates dependencies on demand (what I wanted). Lazy envy need when the dependence should be implemented without its creation.
alvina.Herman answered on July 2nd 19 at 18:23
It is impossible from the point of view of the language itself. If you have a normal field of type object - or null if the injection has not worked, or null if the injection has worked. It is impossible in principle to make the field was not null and lazily initialized when you first appeal to him
That is, the answer to your question is "no". Dagger and nothing to do with it :)
Another question arises: do you really need so they are all created on demand? You feel a noticeable drawdown performance when you initialize the object graph? What is really the problem of lazy initialization?