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

네트워트 연결 상태 Repository로 구현 #85

Merged
merged 3 commits into from
Dec 8, 2022

Conversation

bngsh
Copy link
Collaborator

@bngsh bngsh commented Dec 7, 2022

😎 작업 내용

  • 안드로이드 아키텍처 권장사항을 따르기 위해 네트워크 연결 상태를 repository를 구현하여 노출시킴

🧐 변경된 내용

  • 네트워크 연결 상태 로직에서 deprecated된 메소드 버전 분기 처리
  • domain 모듈에 NetworkRepository 생성

🥳 동작 화면

러닝 시작 화면 인증글 작성 화면

🤯 이슈 번호

  • 이슈 없음

@bngsh bngsh added 리뷰요청 병희 ⛔️머지금지❗️⛔️ 확인할 것이 있어요!! 머지 금지!! labels Dec 7, 2022
Copy link
Member

@soopeach soopeach left a 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
Copy link
Member

Choose a reason for hiding this comment

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

isNetworkConnected는 어떨까요?
Context의 범위가 너무너무 커서 조금 더 구체적으로 명시해주면 좋을 것 같아요!

Copy link
Collaborator Author

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 ->
Copy link
Member

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)
Copy link
Member

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)을 사용하신건가요??

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

요기선 asStateFlow를 사용 안 하신 이유가 있으실까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

혹시 이렇게 정의하면 _networkConnectionState의 subscriberCount가 잡힐까 해서 바꿨었는데 어떻게 해도 잡히지 않았어서 asStateFlow로 바꿔보도록 하겠습니다

@bngsh bngsh removed the ⛔️머지금지❗️⛔️ 확인할 것이 있어요!! 머지 금지!! label Dec 8, 2022
@bngsh bngsh force-pushed the feat/network_connectivity branch from dc54783 to cdfc9a2 Compare December 8, 2022 03:26
@@ -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" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

data 모듈의 매니페스트에 추가하는 게 맞나 싶어서 팀원분들이랑 얘기 나눠봤는데, data도 안드로이드 모듈이기 때문에 전혀 이상하지 않다는 의견을 받았습니다

Copy link
Collaborator Author

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

혹시 이렇게 정의하면 _networkConnectionState의 subscriberCount가 잡힐까 해서 바꿨었는데 어떻게 해도 잡히지 않았어서 asStateFlow로 바꿔보도록 하겠습니다

@bngsh bngsh merged commit fd2a23a into develop Dec 8, 2022
@soopeach soopeach deleted the feat/network_connectivity branch December 8, 2022 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants