-
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/#121 news number api #124
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.
๋ฐค๋ฆ๊ฒ ๊ณ ์๋ง์ผ์ จ์ต๋๋ค~
}.launchIn(lifecycleScope) | ||
} | ||
|
||
private suspend fun saveNumberFromServerToLocal() { |
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.
์๊ฑด ๋ทฐ๋ชจ๋ธ์ ํจ์๋ก ๋ ๊ฐ ์ ์์๊ฒ ๊ฐ์๋ฐ
๋ณํ๋ ์ซ์ ๊ฐ๋ค๋ง ํ๋ผ๋ฏธํฐ๋ก ๋๊ธฐ๊ณ ๋๋จธ์ง๋ ๋ทฐ๋ชจ๋ธ์์ ๋ก์ง์ ์์ฑํด๋ ๋ ๊ฒ ๊ฐ์์
๊ทธ๋ฐ๋ฐ ํน์ suspend๋ก ์ ์ธํ ์ด์ ๊ฐ ์์๊น์?
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.
์ ๋ ์ด ๋ถ๋ถ์ด ๊ถ๊ธํฉ๋๋ค
๊ทธ๋ฆฌ๊ณ ์๋ฒ num ์ด๋ ๋ก์ปฌ num ๋น๊ต ๋ก์ง์ ๋ทฐ ๋ชจ๋ธ์์ ์์ฑํ๊ณ ๊ทธ ๊ฒฐ๊ณผ๋ง 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.
viewModel์์ flow first ๋์ ํด๋น ํจ์๋ฅผ suspend ์ฒ๋ฆฌํด์ ์ด๋ ๊ฒ ํ์ด๋ฏธ๋ค..
๋ฐ๊พธ๊ณ ๋ ์ถ์๋ฐ ๋ค๋ฅธ ํ์ ๋์ ์ค๋ ์์๋ ์์ ๋ถ๊ฐํ ๊ฒ ๊ฐ์์ ํฌ๊ฒ ๋ฌธ์ ๋๋๊ฒ ์๋๋ผ๋ฏ.. ๋์ค์ ์์ ํ๊ณ ์ํผ์
} | ||
|
||
NewsTabType.NOTICE.idx -> { | ||
trackEvent(CLICK_NOTICE) | ||
setBadgeOnNews(NewsTabType.NOTICE.idx, false) | ||
lifecycleScope.launch { viewModel.saveNoticeNumber(serverNoticeNumber) } |
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.
p3 : saveNoticeNumber๊ฐ viewmodel scope์์ ์คํ๋๋ ํจ์๋ผ๋ฉด ์ฝ๋ฃจํด ์ค์ฝํ ์ค์ฒฉ์ ๋ถํ์ํด๋ณด์ฌ์!
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.
๊ทธ๋ฅด๋ค์ ๊ตฟ!
suspend fun saveNewsNumber(newsNumber: Int) = userInfoRepository.saveNewsNumber(newsNumber) | ||
|
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.
save๋ suspend ๋ณด๋จ viewmodel scope๋ด์์ ์ฒ๋ฆฌํ๋๊ฒ ์ด๋ ์ ์ง?
suspend๋ ์ค๋ ๋ ๋ธ๋ฝ์ ๊ฐ๋
์ด ์๋๋ผ ์ปจํ์คํธ ์ค์์นญ ๋ฐ cpu์์ ์ ์ด๊ถ์ ๊ธฐ์ตํ๋ ๋ฆฌ์์ค ๋ญ๋น๋ ์์ง๋ง
์ ์ฅ์ ๊ฒฝ์ฐ ์ค๋จ,์ฌ๊ฐ๋ก ์์ ์ ์ด์ด๋๊ฐ ํ์๋ ์์๊ฒ ๊ฐ๋ค ์๊ฐํด์!
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.
๊ทธ๋ฆฌ๊ณ suspendํจ์์ ํธ์ถ ๋ถ๋ ์ฝ๋ฃจํด ๋น๋ ๋ด๋ถ์์ ์คํ์ ์์ผ์ผ ํ๊ธฐ ๋๋ฌธ์ ๊ฒฐ๊ตญ ๋น์ทํ ์์ ์ด๋ผ ์๊ฐํฉ๋๋ค!
์ด๋ ๊ฒ ๋๋ฉด ๋ถ์์ ํ ์๋ช ์ฃผ๊ธฐ๋ฅผ ๊ฐ์ง view๋จ ๋ณด๋จ viewmodelscope์์ io ์์ ์ ์ฒ๋ฆฌํ๋๊ฒ ๋ ๋์๋ณด์ฌ์!
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.
์ํ ๋ต!
suspend fun getNoticeNumberFromLocal() = userInfoRepository.getNoticeNumber().first() | ||
|
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๋ ๊ณ์ํด์ ๋ฐ์ดํฐ์คํธ๋ฆผ์ ๋ฐฉ์ถํ๋ค๋ ์ฅ์ ์ด ์์ด์!
first()๋ณด๋จ collectํ๊ฑฐ๋ stateinํด์ ๋ณ๊ฒฝ๊ฐ์ด ๊ฐ์ง ๋์์ผ๋ฉด ๋ฑ์ง๋ฅผ ๋์ฐ๋ ๋ฐฉ๋ฒ๋ ์์๊ฒ ๊ฐ์์!
์ ์ฅ์ ํด๋ ๊ฐ์ด ๋ณ๊ฒฝ๋๋๋ฐ datastore๋ flow๋ก ์๋์ด ๋๊ธฐ๋๋ฌธ์ ๊ฐ์ด ์ ์ฅ์ด ๋์ด๋ ๋ฐ๋ก ์์ฐ๊ณผ ์๋น๊ฐ ๋์! ๊ทธ๋ผ ๊ตฌ๋ ํ๋(sateflow/statein) ์ชฝ์์ ์ํ๋ณํ๋ฅผ ๊ณง๋ฐ๋ก ์ ์ ์๊ธฐ ๋๋ฌธ์ ์กฐ๊ธ ๋ ํจ์จ์ ์ผ ๊ฒ์ด๋ ์๊ฐ์ด ๋ค์ด์
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.
์ ๊ทผ๋ฐ ์ด์ฐจํผ ์๋ฒ์์ ๊ฐ์ ธ์ค๋๊ฑด restful์ด๋๊น ๋จ๋ฐฉํฅ์ด๊ธฐ ๋๋ฌธ์ first()๋ก ๋๊ธฐ์ ์ผ๋ก ๊ฐ์ ธ์๋ ์๊ด์๊ฒ ๋ค์
์ ๊ทธ๋ฆฌ๊ณ ์ ๋ชฉ , ๋ช๋ถ์ -> ์ด๊ฑฐ ์ ๊ฐ๊ฒฉ 10dp๋ก ํ์ต๋๋ค! |
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.
์ ๊ฐ ์๋ ์๋ฒฝ๋์ ๋ง์ ์ผ๋ค์ด ์์๊ตฐ์
}.launchIn(lifecycleScope) | ||
} | ||
|
||
private suspend fun saveNumberFromServerToLocal() { |
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.
์ ๋ ์ด ๋ถ๋ถ์ด ๊ถ๊ธํฉ๋๋ค
๊ทธ๋ฆฌ๊ณ ์๋ฒ num ์ด๋ ๋ก์ปฌ num ๋น๊ต ๋ก์ง์ ๋ทฐ ๋ชจ๋ธ์์ ์์ฑํ๊ณ ๊ทธ ๊ฒฐ๊ณผ๋ง 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.
๋จ์ ๋ถ๋ถ์ ๋ค์ pr์์ ๋ฐ์ํด์ฃผ์๋ฉด ๋ ๊ฒ ๊ฐ์์!
โ ๐๐ต๐ฒ๐ฐ๐ธ-๐๐ถ๐๐
๐ ๐๐๐๐๐ฒ๐
๐๐ช๐ผ๐ฟ๐ธ ๐๐ฒ๐๐ฐ๐ฟ๐ถ๐ฝ๐๐ถ๐ผ๐ป
๐ท ๐ฆ๐ฐ๐ฟ๐ฒ๐ฒ๐ป๐๐ต๐ผ๐
2024-11-26.2.28.47.mov
2024-11-26.2.42.14.mov
๐ฌ ๐ง๐ผ ๐ฅ๐ฒ๐๐ถ๐ฒ๐๐ฒ๐ฟ๐
์ง์ง ์ค๋๋ง์ ๊ฐ์ ์ ๋นจ๊ณ ํ.. flow ๊ฐ์ซ์ด์
server number๊ฐ local number๋ณด๋ค ํด ๋์๋ง ๋ฑ์ง ๋์ฐ๋๊ฑฐ ๋ง์ฃ ?
๋ก๊ทธ๋ ๋จธ์ง ์ง์ ์ ์ง์ธ๊ฒ์ ์ง์ง ์ค ์์ฐ์์ผ๋ฉด pr ๋ชป์ฌ๋ ธ์
์ ์ ์ผ๋ก ๋์ ์ค ์ฐฌ์ฐํ๊ป ์๊ด์ ^^..
์์ ํ์ด์ง ๊ณต์ง์ฌํญ title, content ์๋ 18, 50์ ์ ํ์ธ๋ฐ ๋งํ compose๋ ๊ทธ๊ฒ ์ฝ์ง ์์์ ์ผ๋จ maxline์ผ๋ก ์ ์ฝ ๊ฑธ์์ด์ ์ฉ..