-
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
[feature/semin7]: 7주차 과제제출 #13
base: develop
Are you sure you want to change the base?
Conversation
|
||
data class SuccessGetMusicList( | ||
val data: SoptGetMusicData | ||
): HomeState() |
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.
의진님은 state 관리 따로, data 관리 따로 하는 것이 좋은 것 같나요?
아니면 지금처럼 state에서 response 값도 같이 받아주는 것이 좋다고 생각하나요?
저도 처음에는 state에서 response 값도 받아서 같이 관리해주는 것이 좋다고 생각했었는데
대환님 말씀 들어보니까 뭔가 state에서 response 관리하는 것이 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.
오 State 관리와 data 관리를 따로 한다는 관점에 대해서는 깊게 생각해보지 않았는데요. 현재 제가 사용하고 있는 UI State의 사용 이유가 결국 View단에서 State에 따라서만 View가 보여져야하는 형태를 핸들링 할 수 있다는 부분이 유지보수 측면에서 매력적이기 때문입니다. 결국 View가 State에 따라 변경되게 하려면 비즈니스 로직에서 받아오는 data가 State내에 필수적으로 필요할 것 같습니다. 어떻게 보면 MVI의 느낌의 패턴이라고 생각하시면 됩니다.
만약 데이터를 따로 관리하게 된다면, Success인 State에서 data를 따로 observable한 변수를 통해 처리하는 방법을 생각하시는 걸까요?? 이 부분에 있어서 다른 패턴을 적용할 수 있는 예제를 보여주신다면 저도 확인해보겠습니다!!
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.
고생하셨습니다.
@Serializable | ||
data class SoptPostMusicResponse( | ||
@SerialName("data") | ||
val data: Data? = null, |
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.
SerialName을 사용한다면 변수명을 다른 이름으로 지정해도 되지 않을까요?
|
||
import kotlinx.serialization.Serializable | ||
|
||
data class SoptGetMusicData( |
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.
https://developer.android.com/topic/architecture/data-layer?hl=ko#business-models
이 부분 참고해서 데이터 클래스 네이밍 지어봐도 괜찮을 것 같네요
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 musicDao: MusicDao, | ||
private val soptMusicService: SoptMusicService |
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.
굳
class CommonExtension { | ||
private fun Int.toRequestBody() = toString().toRequestBody("text/plain".toMediaTypeOrNull()) | ||
} |
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.
class CommonExtension { | |
private fun Int.toRequestBody() = toString().toRequestBody("text/plain".toMediaTypeOrNull()) | |
} | |
private fun Int.toRequestBody() = toString().toRequestBody("text/plain".toMediaTypeOrNull()) |
코틀린이니까 파일안에 함수만 있어도 될듯
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.
file로 만든게 아니라 class로 만들었었네요 이런 실수를 ㅋㅎㅋㅎㅋㅎ 감사합니다
private val launcher = registerForActivityResult(ActivityResultContracts.GetContent()) | ||
{ imageUri: Uri? -> | ||
this.imageUri = imageUri ?: Uri.EMPTY | ||
binding.ivAddImage.load(imageUri) | ||
} |
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.
pickvisualmedia?
@Test | ||
|
||
fun getMusicList() { | ||
CoroutineScope(Dispatchers.IO).launch { |
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.
안드로이드에서 test시에 코루틴을 사용하는 경우에는 runTest를 사용하는 편입니다.
Description
PR point
Screenshot
device-2023-06-23-201910.webm