android - Provide method dependendies -
in documentation says @provides methods may have dependencies on own, like:
@provides pump providepump(thermosiphon pump) { return pump; }
what change if write that:
@provides pump providepump() { return new thermosiphon(); }
and in first snipped: method pump from?
the documentation shows thermosiphon
class:
class thermosiphon implements pump { private final heater heater; @inject thermosiphon(heater heater) { this.heater = heater; } ... }
the constructor of class annotated @inject
. lets dagger know use constructor whenever thermosiphon
necessary, , automatically supplies heater
instance it, don't have to.
it fine create new thermospihon
instance yourself, dagger saves trouble doing this. example, need heater
reference somewhere if manually. dagger about, don't have tedious repetitive work.