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

๐Ÿš€ 3๋‹จ๊ณ„ - GitHub(UI ์ƒํƒœ) #33

Open
wants to merge 11 commits into
base: simuelunbo
Choose a base branch
from

Conversation

simuelunbo
Copy link

์•ˆ๋…•ํ•˜์„ธ์š”
๋Šฆ์—ˆ์ง€๋งŒ ์ด๋ฒˆ 3๋‹จ๊ณ„ ๋ฏธ์…˜๋„ ๋ฆฌ๋ทฐ ์ž˜ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค ๐Ÿ™

Copy link

@namjackson namjackson left a comment

Choose a reason for hiding this comment

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

์•ˆ๋…•ํ•˜์„ธ์š” ์ค€๋ณด๋‹˜!
3๋‹จ๊ณ„ ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค :) ์ž˜ ๊ตฌํ˜„ํ•ด์ฃผ์…จ๋„ค์š” !
๋ช‡๊ฐ€์ง€ ์ฐธ๊ณ ํ•˜์‹ค๋งŒํ•œ ์ฝ”๋ฉ˜ํŠธ ๋“œ๋ ธ์œผ๋‹ˆ, ํ™•์ธํ•ด์ฃผ์„ธ์š” :)
๋งˆ์ง€๋ง‰๊นŒ์ง€ ํ™”์ดํŒ…์ž…๋‹ˆ๋‹ค!

import nextstep.github.ui.theme.GithubTheme

@Composable
fun GithubRepoSuccess(

Choose a reason for hiding this comment

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

GithubRepoSuccess๋ผ๋Š” ์ด๋ฆ„์€ ๋ฐ์ดํ„ฐ ๊ด€์ ์˜ ๋„ค์ด๋ฐ์•„๋‹๊นŒ์š”?
GithubRepoList ๊ฐ™์€ ์ง๊ด€์ ์ธ ๋„ค์ด๋ฐ์ด ์ข€๋” ๊ฐ€๋…์„ฑ์žˆ์ง€ ์•Š์„๊นŒ์š” :)

@Composable
private fun GithubRepoSuccessPreview() {
GithubTheme {
GithubRepoSuccess(

Choose a reason for hiding this comment

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

๋ฆฌ์ŠคํŠธ๊ฐ€ ๋น„์–ด์žˆ์„๋•Œ๋Š” ์–ด๋–ค ํ™”๋ฉด์ด ๋‚˜์˜ค๋‚˜์š”?
์š”๊ตฌ์‚ฌํ•ญ ๋ชฉ๋ก์ด ๋นˆ ๊ฒฝ์šฐ์—๋Š” ๋นˆ ํ™”๋ฉด UI๋ฅผ ๋…ธ์ถœํ•œ๋‹ค.(ํ”ผ๊ทธ๋งˆ ์ฐธ์กฐ)์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š” :)

message = context.getString(R.string.error_message),
actionLabel = context.getString(R.string.error_retry)
)
if (snackBarResult == SnackbarResult.ActionPerformed) run { viewModel::retryGithubRepo }

Choose a reason for hiding this comment

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

๋ณดํ†ต ๋ฒ”์œ„ ์ง€์ •ํ•จ์ˆ˜๋Š” ์–ธ์ œ์“ฐ์‹œ๋‚˜์š”?
๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•˜๊ฑฐ๋‚˜, ๊ฐ€๋…์„ฑ์„ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๊ณคํ•˜์ง€๋งŒ
ํ˜„์žฌ๋Š” ๋ฌด์˜๋ฏธ ํ•ด๋ณด์ด๊ณ , ์˜คํžˆ๋ ค ์‹ค์ˆ˜๋ฅผ ์œ ๋ฐœํ•˜๋Š” ์œ„ํ—˜ํ•œ ์ฝ”๋“œ๋Š” ์•„๋‹๊นŒ์š” :)

run { viewModel::retryGithubRepo } ์˜ ๊ฒฐ๊ณผ๊ฐ’์€ ๋ฌด์—‡์ผ๊นŒ์š”? :)

Choose a reason for hiding this comment

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

ํ•ด๋‹น ์ฝ”๋“œ๊ฐ€ ๋™์ž‘ํ•˜๋Š”์ง€ ํ…Œ์ŠคํŠธํ• ์ˆ˜์žˆ๋Š” ์ฝ”๋“œ๋ฅผ ์งœ๋ด๋„ ์ข‹์„๊ฑฐ ๊ฐ™์•„์š” :)

Comment on lines +105 to +114
val coroutineScope = rememberCoroutineScope()
val snackBarHostState = remember { SnackbarHostState() }
LaunchedEffect(Unit) {
coroutineScope.launch {
snackBarHostState.showSnackbar(
message = "์—๋Ÿฌ ๋ฉ”์„ธ์ง€",
actionLabel = "์žฌ์‹œ๋„"
)
}
}

Choose a reason for hiding this comment

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

์ค€๋ณด๋‹˜์ด ์ƒ๊ฐํ•˜์‹œ๋Š” Preview์˜ ๊ธฐ์ค€์€ ๋ฌด์—‡์ธ๊ฐ€์š” :)
์œ„์˜ ๋กœ์ง์€ Preview๋กœ ๋ณด๊ธด ํž˜๋“ค์ง€ ์•Š์„๊นŒ์š”?

์ด๋ฒคํŠธ๋“ค์€ ui ํ…Œ์ŠคํŠธ๋กœ ์ž‘์„ฑํ•ด๋ณด๋ฉด ์–ด๋–จ๊นŒ์š”? :)


private fun fetchRepositories() {
viewModelScope.launch(CoroutineExceptionHandler { _, throwable ->
_errorFlow.tryEmit(throwable)

Choose a reason for hiding this comment

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

์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด, tryEmit์ด ์ž˜ ์ž‘๋™ํ• ๊นŒ์š”? :)

}) {
_githubUiState.update { it.copy(isLoading = true) }
val repositories = githubRepoRepository.getRepositories("next-step")
_githubUiState.update { it.copy(repositories = repositories, isLoading = false) }

Choose a reason for hiding this comment

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

์ค€๋ณด๋‹˜์ด ์ƒ๊ฐํ•˜๋Š” UiState๋ฅผ ์„ค๊ณ„ํ•˜๋Š” ๊ธฐ์ค€์ด ๋ฌด์—‡์ธ๊ฐ€์š”?
์ˆœ์ˆ˜ํ•˜๊ฒŒ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค :)

Comment on lines +39 to +40
LaunchedEffect(true) {
viewModel.errorFlow.collect {

Choose a reason for hiding this comment

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

๊ฐ•์˜ ์‹œ๊ฐ„์—์„œ๋„ ๋‹ค๋ฃฌ ๋‚ด์šฉ์ด๊ธดํ•œ๋ฐ,
https://medium.com/androiddevelopers/viewmodel-one-off-event-antipatterns-16a1da869b95
์ค€๋ณด๋‹˜์˜ ์˜๊ฒฌ์ด ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค! (์˜๊ฒฌ๋งŒ ์ฃผ์…”๋„ ์ข‹์„๊ฑฐ ๊ฐ™์•„์š”!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants