Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Introduce SharedPreferences into object graph
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
  • Loading branch information
msfjarvis committed Jan 16, 2020
1 parent f1604ad commit f1a60ff
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package dev.msfjarvis.daggertutorial.di

import android.content.Context
import android.content.SharedPreferences
import androidx.preference.PreferenceManager
import dagger.Component
import dagger.Module
import dagger.Provides
import dagger.Reusable
import javax.inject.Singleton

@Singleton
@Component(modules = [AppModule::class])
interface AppComponent {

val preferences: SharedPreferences
}

@Module
object AppModule {

@Provides
@Reusable
fun provideSharedPrefs(context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
}

0 comments on commit f1a60ff

Please sign in to comment.