-
Notifications
You must be signed in to change notification settings - Fork 5
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
네트워트 연결 상태 Repository로 구현 #85
Conversation
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.
넘 깔끔하네요
} | ||
} | ||
|
||
val Context.isConnected: Boolean |
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.
isNetworkConnected는 어떨까요?
Context의 범위가 너무너무 커서 조금 더 구체적으로 명시해주면 좋을 것 같아요!
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.
네 반영하겠습니다!
@@ -27,8 +33,8 @@ class CreateRunningPostViewModel @Inject constructor( | |||
val runningPostContent = MutableStateFlow<String?>(null) | |||
|
|||
val createPostButtonEnableState: StateFlow<Boolean> | |||
get() = runningPostContent.map { content -> | |||
content.isNullOrBlank().not() | |||
get() = runningPostContent.combine(networkState) { content, networkState -> |
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.
오.. 네트워크 연결 상태에 따라서 아예 버튼을 비활성화하는 것도 좋네요!
.map { isConnected -> | ||
if (isConnected) NetworkState.Connection else NetworkState.DisConnection | ||
} | ||
.debounce(500) |
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.
네트워크 연결관련된 flow가 감지되었을 때 0.5초이상 동일한 연결상태일 경우에만 처리를 해주기 위해서 debounce(500)을 사용하신건가요??
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.
굉장한 디테일이네요 굳굳
private val _networkState = MutableStateFlow<NetworkState>(NetworkState.UnInitialized) | ||
val networkState: StateFlow<NetworkState> get() = _networkState.asStateFlow() | ||
private val _networkConnectionState = MutableStateFlow<NetworkState>(NetworkState.UnInitialized) | ||
val networkConnectionState: StateFlow<NetworkState> = _networkConnectionState |
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.
요기선 asStateFlow를 사용 안 하신 이유가 있으실까요?
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.
혹시 이렇게 정의하면 _networkConnectionState의 subscriberCount가 잡힐까 해서 바꿨었는데 어떻게 해도 잡히지 않았어서 asStateFlow로 바꿔보도록 하겠습니다
dc54783
to
cdfc9a2
Compare
@@ -1,4 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |||
|
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
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 모듈의 매니페스트에 추가하는 게 맞나 싶어서 팀원분들이랑 얘기 나눠봤는데, data도 안드로이드 모듈이기 때문에 전혀 이상하지 않다는 의견을 받았습니다
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 모듈이 domain밖에 알고있지 않고, domain은 자바/코틀린 라이브러리 모듈이기 때문에 매니페스트가 없어서 data 모듈의 매니페스트에 밖에 정의할 수 없다!
private val _networkState = MutableStateFlow<NetworkState>(NetworkState.UnInitialized) | ||
val networkState: StateFlow<NetworkState> get() = _networkState.asStateFlow() | ||
private val _networkConnectionState = MutableStateFlow<NetworkState>(NetworkState.UnInitialized) | ||
val networkConnectionState: StateFlow<NetworkState> = _networkConnectionState |
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.
혹시 이렇게 정의하면 _networkConnectionState의 subscriberCount가 잡힐까 해서 바꿨었는데 어떻게 해도 잡히지 않았어서 asStateFlow로 바꿔보도록 하겠습니다
😎 작업 내용
🧐 변경된 내용
🥳 동작 화면
🤯 이슈 번호