Sobes.tech
Middle+

List two ways to transfer objects when creating an instance of the Dagger library.

sobes.tech AI

Answer from AI

  1. Using a module annotated with @Module. Inside the module, methods annotated with @Provides supply dependency instances.

    @Module
    class MyModule {
    
        @Provides
        fun provideMyObject(): MyObject {
            return MyObject()
        }
    }
    
  2. Using a constructor annotated with @Inject. Dagger can create an instance of such a class if all its constructor dependencies are also provided.

    class MyObject @Inject constructor() {
    
        // ...
    }
    
List two ways to transfer objects when creating an… - sobes.tech