-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Preferences Datastore 적용 #15
base: develop
Are you sure you want to change the base?
Conversation
) : SharedPreferenceDataSource { | ||
override var checkLogin: Boolean | ||
get() = sharedPreferences.getBoolean(CHECK_LOGIN, false) | ||
set(value) = sharedPreferences.edit { putBoolean(CHECK_LOGIN, value) } | ||
get() = runBlocking { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runBlocking을 사용할때 유의해야할 점은 뭘까요 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다
datastore에 관한 di모듈은 data 모듈 안에서만 있어도 될것 같아요!
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object SharedPreferenceModule { | ||
private const val PREFERENCE_NAME = "chanu_dataStore" | ||
private val Context.datastore by preferencesDataStore( | ||
name = PREFERENCE_NAME | ||
) | ||
|
||
@Provides | ||
@Singleton | ||
fun providesLocalPreferences( | ||
@ApplicationContext context: Context | ||
): SharedPreferences = | ||
EncryptedSharedPreferences.create( | ||
context, | ||
context.packageName, | ||
MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build(), | ||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, | ||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM | ||
) | ||
) = context.datastore | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 모듈 data모듈로 이동해 주세요!
지금은 app모듈, data모듈 둘다 라이브러리에 의존해야하는데 data모듈에서 필요할때만 사용해도 될것 같아요
suspend fun saveUserInfo(userDto: UserDto?) | ||
suspend fun getUserInfo(): UserDto | ||
suspend fun clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suspend를 사용해도 되고 타입을 Flow타입으로 감싸주어도 될것 같습니다!
전 후자로 진행했어요
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵
💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴