Skip to content

Commit 9739280

Browse files
committed
📦 NEW: inject repository using hilt
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
1 parent a3ec094 commit 9739280

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.github.swent.echo.di
2+
3+
import android.app.Application
4+
import com.github.swent.echo.data.repository.IRepository
5+
import com.github.swent.echo.data.repository.Repository
6+
import com.github.swent.echo.data.repository.datasources.Cache
7+
import com.github.swent.echo.data.repository.datasources.LocalDataSource
8+
import com.github.swent.echo.data.repository.datasources.RemoteDataSource
9+
import com.github.swent.echo.data.repository.datasources.Supabase
10+
import dagger.Module
11+
import dagger.Provides
12+
import dagger.hilt.InstallIn
13+
import dagger.hilt.components.SingletonComponent
14+
import io.github.jan.supabase.SupabaseClient
15+
16+
@Module
17+
@InstallIn(SingletonComponent::class)
18+
object RepositoryModule {
19+
20+
@Provides
21+
fun provideRepository(application: Application, supabaseClient: SupabaseClient): IRepository {
22+
val localDataSource: LocalDataSource = Cache(application)
23+
val remoteDataSource: RemoteDataSource = Supabase(supabaseClient)
24+
25+
return Repository(localDataSource, remoteDataSource)
26+
}
27+
}

0 commit comments

Comments
 (0)