45 lines
1.1 KiB
Kotlin
45 lines
1.1 KiB
Kotlin
package chats.di
|
|
|
|
import chats.data.remote.api.ChatApi
|
|
import chats.data.remote.signalr.ChatHubClient
|
|
import chats.data.repository.ChatRepositoryImpl
|
|
import chats.domain.repository.ChatRepository
|
|
import core.database.data.MessageDao
|
|
import core.network.ServerConfig
|
|
import core.security.TokenManager
|
|
import dagger.Module
|
|
import dagger.Provides
|
|
import dagger.hilt.InstallIn
|
|
import dagger.hilt.components.SingletonComponent
|
|
import retrofit2.Retrofit
|
|
import javax.inject.Singleton
|
|
|
|
@Module
|
|
@InstallIn(SingletonComponent::class)
|
|
object ChatModule {
|
|
|
|
@Provides
|
|
@Singleton
|
|
fun provideChatApi(retrofit: Retrofit): ChatApi {
|
|
return retrofit.create(ChatApi::class.java)
|
|
}
|
|
|
|
@Provides
|
|
@Singleton
|
|
fun provideChatRepository(
|
|
api: ChatApi,
|
|
tokenManager: TokenManager,
|
|
serverConfig: ServerConfig,
|
|
messageDao: MessageDao,
|
|
hubClient: chats.data.remote.signalr.ChatHubClient
|
|
): ChatRepository {
|
|
return ChatRepositoryImpl(api, tokenManager, serverConfig, messageDao, hubClient)
|
|
}
|
|
|
|
@Provides
|
|
@Singleton
|
|
fun provideChatHubClient(): ChatHubClient {
|
|
return ChatHubClient()
|
|
}
|
|
}
|