-
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
[TNT-140] DataStore 구축 #32
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
aa59df7
[TNT-140] move: data 모듈 -> data:network 모듈로 세분화
hoyahozz beabcf4
[TNT-140] chore: data:storage 모듈 최초 생성
hoyahozz 521d6e0
[TNT-140] chore: dataStore 종속성 추가
hoyahozz eb03146
[TNT-140] chore: data:repository 모듈 최초 생성
hoyahozz 4fefefb
[TNT-140] move: Repository 파일 이관
hoyahozz 459bf2f
[TNT-140] feat: 세션 DataStore 최초 세팅
hoyahozz 2827339
[TNT-140] feat: 세션 DataSource 구현
hoyahozz c2b936b
[TNT-140] style: 미사용 XML 네임 스페이스 제거
hoyahozz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
data/network/src/main/java/co/kr/data/network/service/TnTService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package co.kr.data.network.service | ||
|
||
interface TnTService |
11 changes: 11 additions & 0 deletions
11
data/network/src/main/java/co/kr/data/network/source/TnTDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package co.kr.data.network.source | ||
|
||
import co.kr.data.network.service.TnTService | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Suppress("UnusedPrivateProperty") | ||
@Singleton | ||
class TnTDataSource @Inject constructor( | ||
private val tntService: TnTService, | ||
) |
2 changes: 1 addition & 1 deletion
2
.../tnt/data/model/tnt/request/TnTRequest.kt → ...kr/data/network/tnt/request/TnTRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nt/data/model/tnt/response/TnTResponse.kt → .../data/network/tnt/response/TnTResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import co.kr.tnt.setNamespace | ||
|
||
plugins { | ||
id("tnt.android.library") | ||
id("tnt.android.hilt") | ||
} | ||
|
||
android { | ||
setNamespace("data.repository") | ||
} | ||
|
||
dependencies { | ||
implementation(projects.domain) | ||
implementation(projects.data.network) | ||
implementation(projects.data.storage) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
12 changes: 12 additions & 0 deletions
12
data/repository/src/main/java/co/kr/data/repository/TnTRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package co.kr.data.repository | ||
|
||
import co.kr.data.network.source.TnTDataSource | ||
import co.kr.data.storage.source.SessionDataSource | ||
import co.kr.tnt.domain.repository.TnTRepository | ||
import javax.inject.Inject | ||
|
||
@Suppress("UnusedPrivateProperty") | ||
internal class TnTRepositoryImpl @Inject constructor( | ||
private val tnTDataSource: TnTDataSource, | ||
private val sessionDataSource: SessionDataSource, | ||
) : TnTRepository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
data/src/main/java/co/kr/tnt/data/repository/TnTRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import co.kr.tnt.setNamespace | ||
|
||
plugins { | ||
id("tnt.android.library") | ||
id("tnt.android.hilt") | ||
} | ||
|
||
android { | ||
setNamespace("data.storage") | ||
} | ||
|
||
dependencies { | ||
implementation(projects.domain) | ||
|
||
implementation(libs.androidx.datastore.preferences) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
25 changes: 25 additions & 0 deletions
25
data/storage/src/main/java/co/kr/data/storage/di/StorageModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package co.kr.data.storage.di | ||
|
||
import android.content.Context | ||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.preferencesDataStore | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal object StorageModule { | ||
private const val SESSION_STORAGE_NAME = "SESSION_STORAGE" | ||
private val Context.sessionDataStore by preferencesDataStore(name = SESSION_STORAGE_NAME) | ||
|
||
@Provides | ||
@Singleton | ||
fun provideSessionDataStore( | ||
@ApplicationContext context: Context, | ||
): DataStore<Preferences> = context.sessionDataStore | ||
} |
29 changes: 29 additions & 0 deletions
29
data/storage/src/main/java/co/kr/data/storage/source/SessionDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package co.kr.data.storage.source | ||
|
||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.edit | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class SessionDataSource @Inject constructor( | ||
private val sessionPreferences: DataStore<Preferences>, | ||
) { | ||
val sessionId: Flow<String> = sessionPreferences.data.map { preferences -> | ||
preferences[SESSION_ID] ?: "" | ||
} | ||
|
||
suspend fun updateSessionId(sessionId: String) { | ||
sessionPreferences.edit { preferences -> | ||
preferences[SESSION_ID] = sessionId | ||
} | ||
} | ||
|
||
companion object { | ||
private val SESSION_ID = stringPreferencesKey("SESSION_ID") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 사용할 때 DataSource를 나누는 기준은 어떻게 될까요?!
예를들어 SessionDataStore가
세션 관련 데이터
를 관리하고 있는 것처럼 데이터의 용도에 따라 나누면 될까요?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.
넵넵 맞습니다~!!