Replace module interfaces with objects

Change-Id: Ieab7533120e7b8d5a770963e37b9db405e229630
pull/2/head
Adetunji Dahunsi 3 years ago
parent 8b1852cf5e
commit e089012a8d

@ -28,26 +28,24 @@ import dagger.hilt.components.SingletonComponent
@Module @Module
@InstallIn(SingletonComponent::class) @InstallIn(SingletonComponent::class)
interface DaosModule { object DaosModule {
companion object { @Provides
@Provides fun providesAuthorDao(
fun providesAuthorDao( database: NiADatabase,
database: NiADatabase, ): AuthorDao = database.authorDao()
): AuthorDao = database.authorDao()
@Provides @Provides
fun providesTopicsDao( fun providesTopicsDao(
database: NiADatabase, database: NiADatabase,
): TopicDao = database.topicDao() ): TopicDao = database.topicDao()
@Provides @Provides
fun providesEpisodeDao( fun providesEpisodeDao(
database: NiADatabase, database: NiADatabase,
): EpisodeDao = database.episodeDao() ): EpisodeDao = database.episodeDao()
@Provides @Provides
fun providesNewsResourceDao( fun providesNewsResourceDao(
database: NiADatabase, database: NiADatabase,
): NewsResourceDao = database.newsResourceDao() ): NewsResourceDao = database.newsResourceDao()
}
} }

@ -28,16 +28,14 @@ import javax.inject.Singleton
@Module @Module
@InstallIn(SingletonComponent::class) @InstallIn(SingletonComponent::class)
interface DatabaseModule { object DatabaseModule {
companion object { @Provides
@Provides @Singleton
@Singleton fun providesNiADatabase(
fun providesNiADatabase( @ApplicationContext context: Context,
@ApplicationContext context: Context, ): NiADatabase = Room.databaseBuilder(
): NiADatabase = Room.databaseBuilder( context,
context, NiADatabase::class.java,
NiADatabase::class.java, "nia-database"
"nia-database" ).build()
).build()
}
} }

Loading…
Cancel
Save