-
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
feat: 데이타스토어 정비 및 기능 추가 #337
Conversation
import javax.inject.Named | ||
|
||
class UserPreferencesDataSource @Inject constructor( | ||
@Named("userPreferencesDataStore") private val dataStore: DataStore<Preferences>, |
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.
a: 우리 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.
원래 두개를 만들었는데 하나를 지웠습니다!!
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.
그럼 Named 어노테이션은 필요 없을 것 같아요!
@Named("userPreferencesDataStore") private val dataStore: DataStore<Preferences>, | ||
) { | ||
|
||
object PreferencesKey { |
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.
c: 여기 위치한 이유가 무엇인가요?
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.
드나에서 이렇게 쓰더라구요 데이터소스가 직접 키값을 가지고 있는 것도 괜찮다고 생각했습니다!
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 fun fetchAccessToken(): String { | ||
return dataStore.data.first()[PreferencesKey.ACCESS_TOKEN_KEY] ?: "" |
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.
c: orEmpty() 어떠심?
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.
코틀린스럽고 좋은듯요
@Singleton | ||
@Provides | ||
fun provideUserPreferencesDataStore(@ApplicationContext context: Context): DataStore<Preferences> { | ||
private fun Context.createDataStore(preferencesName: String): DataStore<Preferences> { |
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.
c: DataStoreModule에 위치하는건 별로인 것 같아요
) | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
@Named("userPreferencesDataStore") |
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.
c: Named가 필요한 이유가 무엇인가용
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.
데이터스토어 종류가 추가되면 충돌이 발생하더라구요? 그래서 추가했던 것 같습니다 🤔
혹시 하나의 데이터스토어를 모두가 공유해야하나요...?
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.
하나의 데이터스토어밖에 사용하고 있지 않으니 불필요한 어노테이션 같아요
import javax.inject.Inject | ||
import javax.inject.Named | ||
|
||
class UserPreferencesDataSource @Inject constructor( |
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.
c: 왜 dataSource인가요?
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.
이 부분 역시 드나에서 이렇게 사용하더군요! 데이터스토어가 아닌 다른 로컬 저장소로 교체되더라도 네이밍이 바뀌지 않아도 될 것 같아서 괜찮다고 생각해서 채택했습니다 :)
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.
드나나 구글 공식 레포가 정답인것은 아닙니다! 그리고 적어주신 이유는 레포지토리 이름으로도 가능한 내용입니다
특히 클래스명은 팀 컨벤션이니까 적용전에 상의해보는 것도 좋겠습니다 :)
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.
코드 확인했습니다. 그런데 resovled 하려는 이슈와 피알 내용이 다른 것 같아서 다시 수정하셔야 할 것 같아요!
이슈와 피알 내용이 다른 것은 제가 토큰 관리 쪽을 요청드려서 그런거 같습니다! |
import javax.inject.Inject | ||
|
||
class UserRepository @Inject constructor( | ||
private val userApi: UserApi, | ||
private val dataStore: DataStore<Preferences>, |
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.
r: 않이. 이전에도 비슷한 리뷰 남긴것 같은데.... 공식문서에서도 구현체를 밝히는 네이밍은 권장하지 않아요 :(
…o feat/321 # Conflicts: # app/src/main/java/com/teamwss/websoso/common/util/ExtentionFuction.kt
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.
고생하셨습니다
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴
레퍼런스는 드로이드나이츠하고 나우인안드로이드, 오프로드에서 제가 직접 수정한 코드입니다