-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat/#248] 프로필 리팩토링 완료, 이슈 일부 수정 #258
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
477e285
chore: 프로필 정보, 수정 레거시 코드 제거
ThirFir 4bc41a6
fix: 저장한 장소 데이터 변화 실시간 감지 되지 않던 것 수정
ThirFir 8870b58
chore: 프로필 관련 API 레거시 코드 제거 및 새 구현으로 마이그레이션
ThirFir 8c98cc2
fix: 지역인증 건너뛰기 display 안되던 문제, 뒤로가기 오동작 문제 수정
ThirFir 68fa63c
feat: 데이터 변화 감지 기능 인터페이스 구현
ThirFir 69544fe
refactor: 인증 지역 데이터 변화 뷰모델에서 감지하도록 수정
ThirFir 0759372
refactor: Presigned url 로직 프로필 Repo -> AconApp Repo로 이동
ThirFir e09d5ae
fix: UpdateProfileRequest 매핑 함수 구현 중 생년월일 padding 붙이는 로직 이슈 수정
ThirFir 90c6059
fix: 초기 지역인증에서 건너뛰기 시 다음화면 이동 로직 정상화
ThirFir 80ffe65
fix: 지역인증 건너뛰기 못 하는 상태일 때 뒤로가기 블락
ThirFir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
core/data/src/main/kotlin/com/acon/core/data/stream/DataStream.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.acon.core.data.stream | ||
|
|
||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.FlowCollector | ||
| import kotlinx.coroutines.flow.MutableSharedFlow | ||
| import kotlinx.coroutines.flow.transformLatest | ||
| import javax.inject.Inject | ||
|
|
||
| interface DataStream { | ||
| suspend fun notifyDataChanged() | ||
| fun <T> subscribe(block: suspend FlowCollector<T>.() -> Unit): Flow<T> | ||
| } | ||
|
|
||
| class DataStreamImpl @Inject constructor() : DataStream { | ||
| private val trigger = MutableSharedFlow<Unit>(replay = 1) | ||
|
|
||
| init { | ||
| trigger.tryEmit(Unit) | ||
| } | ||
|
|
||
| override suspend fun notifyDataChanged() { | ||
| trigger.emit(Unit) | ||
| } | ||
|
|
||
| override fun <T> subscribe(block: suspend FlowCollector<T>.() -> Unit): Flow<T> { | ||
| return trigger.transformLatest { this.block() } | ||
| } | ||
| } | ||
75 changes: 75 additions & 0 deletions
75
core/data/src/test/java/com/acon/core/data/stream/DataStreamImplTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package com.acon.core.data.stream | ||
|
|
||
| import app.cash.turbine.test | ||
| import io.mockk.junit5.MockKExtension | ||
| import kotlinx.coroutines.test.runTest | ||
| import org.junit.jupiter.api.Assertions.assertEquals | ||
| import org.junit.jupiter.api.BeforeEach | ||
| import org.junit.jupiter.api.Test | ||
| import org.junit.jupiter.api.extension.ExtendWith | ||
|
|
||
| @ExtendWith(MockKExtension::class) | ||
| class DataStreamImplTest { | ||
|
|
||
| private lateinit var dataStream: DataStream | ||
|
|
||
| @BeforeEach | ||
| fun setUp() { | ||
| dataStream = DataStreamImpl() | ||
| } | ||
|
|
||
| @Test | ||
| fun `초기 방출 테스트`() = runTest { | ||
| var value = 0 | ||
| val flow = dataStream.subscribe { | ||
| emit(++value) | ||
| } | ||
|
|
||
| flow.test { | ||
| assertEquals(1, awaitItem()) | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun `notifyDataChanged가 flow를 트리거하는지 테스트`() = runTest { | ||
| var value = 0 | ||
| val flow = dataStream.subscribe { | ||
| emit(++value) | ||
| } | ||
|
|
||
| flow.test { | ||
| assertEquals(1, awaitItem()) | ||
| dataStream.notifyDataChanged() | ||
| assertEquals(2, awaitItem()) | ||
| dataStream.notifyDataChanged() | ||
| assertEquals(3, awaitItem()) | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun `여러 구독이 생겼을 때, 한 번의 notify는 모든 구독자에게 전파되어야 한다`() = runTest { | ||
| var value1 = 0 | ||
| val flow1 = dataStream.subscribe<Int> { | ||
| emit(++value1) | ||
| } | ||
|
|
||
| var value2 = 10 | ||
| val flow2 = dataStream.subscribe<Int> { | ||
| emit(++value2) | ||
| } | ||
|
|
||
| flow1.test { | ||
| val f1 = this | ||
| flow2.test { | ||
| val f2 = this | ||
| assertEquals(1, f1.awaitItem()) // flow1의 첫 번째 값은 1 | ||
| assertEquals(11, f2.awaitItem()) // flow2의 첫 번째 값은 11 | ||
|
|
||
| dataStream.notifyDataChanged() | ||
|
|
||
| assertEquals(2, f1.awaitItem()) // flow1의 두 번째 값은 2 | ||
| assertEquals(12, f2.awaitItem()) // flow2의 두 번째 값은 12 | ||
| } | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
이 DataStream을 사용하는 곳을 몇개 봤는데 (프로필? , 인증동네 확인 뷰모델, 온보딩) 왜 이걸 새로 만드셨는지 궁금합니다ㅏ
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.
데이터 변화 알려주는거에요
간단하게, 데이터를 새로 저장하면, 원래 그 데이터를 쓰던곳에선 변화를 감지해야 하잖아요? 그걸 기능화 한것입니다.