Skip to content
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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Eonji-sw
Copy link
Member

@Eonji-sw Eonji-sw commented May 14, 2024

📌𝘐𝘴𝘴𝘶𝘦𝘴

📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯

  • 기존에 구현되어 있던 SharedPreferences -> Preferences Datastore 로 변경하였습니다.
  • Proto Datastore은 뭔가 구현이 빡세보여서 걍 Preferences Datastore로 적용했습니다.
  • SharedPreferences 관련해서 gradle 추가했던건 지웠습니다.
  • 굳이 파일명은 바꾸지 않았습니다.
  • 딱히 이슈가 있진 않았고 생각보다 코드 바꿀게 없어서 맞게 했는지 모르겠네요.

📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵

💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴

  • PR 늦어진 점.. 암 쏘리쏘리 ^^....
  • 첨엔 어케 구현하지 하다가 막상 하고 돌리니까 돼서 이게 왜되노.. 했는데 잘 구현한거겠죠? 😇
  • 만약 맞게 구현한거라면 Preferences Datastore 구현할만 하네욤 ㅋ.ㅋ

@Eonji-sw Eonji-sw self-assigned this May 14, 2024
) : SharedPreferenceDataSource {
override var checkLogin: Boolean
get() = sharedPreferences.getBoolean(CHECK_LOGIN, false)
set(value) = sharedPreferences.edit { putBoolean(CHECK_LOGIN, value) }
get() = runBlocking {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runBlocking을 사용할때 유의해야할 점은 뭘까요 ?

Copy link
Contributor

@chanubc chanubc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다
datastore에 관한 di모듈은 data 모듈 안에서만 있어도 될것 같아요!

Comment on lines 12 to 25
@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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 모듈 data모듈로 이동해 주세요!
지금은 app모듈, data모듈 둘다 라이브러리에 의존해야하는데 data모듈에서 필요할때만 사용해도 될것 같아요

Comment on lines +7 to +9
suspend fun saveUserInfo(userDto: UserDto?)
suspend fun getUserInfo(): UserDto
suspend fun clear()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suspend를 사용해도 되고 타입을 Flow타입으로 감싸주어도 될것 같습니다!
전 후자로 진행했어요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[언지] Preferences Datastore 적용
3 participants