Dagger 2

From bibbleWiki
Revision as of 22:47, 19 December 2020 by Iwiseman (talk | contribs) (Created page with "=Introduction= Dagger is made by Google. Dagger allows you to *Scope dependencies *Bind single instance to life cycles *Only need to build them once *Generates the code at co...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

Dagger is made by Google. Dagger allows you to

  • Scope dependencies
  • Bind single instance to life cycles
  • Only need to build them once
  • Generates the code at compile time

Example Without Dagger

fun buildCar: Car = 
    Car(SturdyFrame(),
    Wheels(),
    RocketEngine())

With Dagger

fun buildCar: Car = 
    DaggerAppComponent
    .builder()
    .build()
    .buildCar()