-
Notifications
You must be signed in to change notification settings - Fork 0
[#534] TodoEditor에서 Todo를 수정하면 HomeView에서 최근 수정 섹션에 해당 Todo가 반영되지 않는 현상을 해결한다 #554
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6040a6a
feat: Todo 수정 및 삭제를 감지하는 버스 구현
opficdev c60f6c6
feat: TodoMutationEvent 방출
opficdev d350929
feat: TodoMutationEvent 기반 홈 화면 갱신
opficdev c1bc46c
refactor: HomeViewCoordinator stream task 관리 개선
opficdev b3e4ee7
refactor: self 처리
opficdev 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
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
37 changes: 37 additions & 0 deletions
37
Application/DevLogData/Sources/Repository/TodoMutationEventBusImpl.swift
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,37 @@ | ||
| // | ||
| // TodoMutationEventBusImpl.swift | ||
| // DevLogData | ||
| // | ||
| // Created by opfic on 6/6/26. | ||
| // | ||
|
|
||
| import Foundation | ||
| import DevLogDomain | ||
|
|
||
| actor TodoMutationEventBusImpl: TodoMutationEventBus { | ||
| private var continuations = [UUID: AsyncStream<TodoMutationEvent>.Continuation]() | ||
|
|
||
| func publish(_ event: TodoMutationEvent) async { | ||
| continuations.values.forEach { $0.yield(event) } | ||
| } | ||
|
|
||
| func events() -> AsyncStream<TodoMutationEvent> { | ||
| let id = UUID() | ||
| let (stream, continuation) = AsyncStream.makeStream(of: TodoMutationEvent.self) | ||
|
|
||
| continuations[id] = continuation | ||
| continuation.onTermination = { [weak self] _ in | ||
| Task { | ||
| await self?.removeContinuation(id: id) | ||
| } | ||
| } | ||
|
|
||
| return stream | ||
| } | ||
| } | ||
|
|
||
| private extension TodoMutationEventBusImpl { | ||
| func removeContinuation(id: UUID) { | ||
| continuations[id] = nil | ||
| } | ||
| } |
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
27 changes: 27 additions & 0 deletions
27
Application/DevLogData/Tests/Repository/TodoMutationEventBusImplTests.swift
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,27 @@ | ||
| // | ||
| // TodoMutationEventBusImplTests.swift | ||
| // DevLogDataTests | ||
| // | ||
| // Created by opfic on 6/6/26. | ||
| // | ||
|
|
||
| import Testing | ||
| import DevLogDomain | ||
| @testable import DevLogData | ||
|
|
||
| struct TodoMutationEventBusImplTests { | ||
| @Test("TodoMutationEventBus는 발행된 이벤트를 관찰자에게 전달한다") | ||
| func todoMutationEventBus는_발행된_이벤트를_관찰자에게_전달한다() async { | ||
| let bus = TodoMutationEventBusImpl() | ||
| let events = await bus.events() | ||
| let task = Task { | ||
| var iterator = events.makeAsyncIterator() | ||
| return await iterator.next() | ||
| } | ||
|
|
||
| await bus.publish(.updated("todo-id")) | ||
|
|
||
| let event = await task.value | ||
| #expect(event == .updated("todo-id")) | ||
| } | ||
| } |
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
12 changes: 12 additions & 0 deletions
12
Application/DevLogDomain/Sources/Entity/TodoMutationEvent.swift
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,12 @@ | ||
| // | ||
| // TodoMutationEvent.swift | ||
| // DevLogDomain | ||
| // | ||
| // Created by opfic on 6/6/26. | ||
| // | ||
|
|
||
| public enum TodoMutationEvent: Equatable, Sendable { | ||
| case updated(String) | ||
| case deleted(String) | ||
| case restored(String) | ||
| } |
11 changes: 11 additions & 0 deletions
11
Application/DevLogDomain/Sources/Protocol/TodoMutationEventBus.swift
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,11 @@ | ||
| // | ||
| // TodoMutationEventBus.swift | ||
| // DevLogDomain | ||
| // | ||
| // Created by opfic on 6/6/26. | ||
| // | ||
|
|
||
| public protocol TodoMutationEventBus: Sendable { | ||
| func publish(_ event: TodoMutationEvent) async | ||
| func events() async -> AsyncStream<TodoMutationEvent> | ||
| } |
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.