-
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
[SCRUM-50] ErrorFeature: 네트워크 에러뷰, 서버통신 에러뷰 UI #57
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
619923e
feature: ErrorFeature module 생성
Jihyun247 3eb4e4f
feature: ErrorFeature Example 모듈과 두 에러뷰 UI
Jihyun247 aa32fa4
feature: StreamListener 모듈 추가 및 모듈 구조 변경
Jihyun247 2c5cae0
add: 에러뷰 이미지 리소스 추가
Jihyun247 6d668c0
feature: StreamListener 모듈 interface & source 초안
Jihyun247 9e16041
feature: loadingView, errorView fullScreen
Jihyun247 6b9a3fd
feature: 네트워크연결끊김 case 추가 및 CatFeature-SelectCat 으로 테스트
Jihyun247 1b1e4d9
feature: 고양이선택, 고양이 이름짓기 stream listener 연결
Jihyun247 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 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 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 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
35 changes: 35 additions & 0 deletions
35
Projects/Core/StreamListener/Interface/StreamListenerInterface.swift
This file contains 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,35 @@ | ||
// | ||
// StreamListenerInterface.swift | ||
// StreamListener | ||
// | ||
// Created by jihyun247 on 11/21/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import Dependencies | ||
import DependenciesMacros | ||
|
||
/* | ||
TODO: | ||
StreamListener를 토스트나 다이얼로그, 에러뷰 등 다양한 상황의 스트림을 만들 수 있도록 둘 것인지, serverState 추적만을 하도록 둘 것인지 정해야함 (네이밍 다시 해야함) | ||
++ NetworkTracking도 그 목적이 StreamListener와 유사함 | ||
*/ | ||
|
||
@DependencyClient | ||
public struct StreamListener { | ||
public var sendServerState: @Sendable (_ state: ServerState) async -> Void | ||
public var updateServerState: @Sendable () -> AsyncStream<ServerState> = { .never } | ||
} | ||
|
||
extension StreamListener: TestDependencyKey { | ||
public static let previewValue = Self() | ||
public static let testValue = Self() | ||
} | ||
|
||
public enum ServerState { | ||
case requestStarted | ||
case requestCompleted | ||
case errorOccured | ||
case networkDisabled | ||
} |
This file contains 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,22 @@ | ||
import ProjectDescription | ||
import ProjectDescriptionHelpers | ||
|
||
@_spi(Core) | ||
@_spi(Shared) | ||
import DependencyPlugin | ||
|
||
let project: Project = .makeTMABasedProject( | ||
module: Core.StreamListener, | ||
scripts: [], | ||
targets: [ | ||
.sources, | ||
.interface, | ||
.tests, | ||
.testing | ||
], | ||
dependencies: [ | ||
.interface: [ | ||
.dependency(rootModule: Shared.self) | ||
] | ||
] | ||
) |
This file contains 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,46 @@ | ||
// | ||
// StreamListener.swift | ||
// StreamListener | ||
// | ||
// Created by jihyun247 on 11/21/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import StreamListenerInterface | ||
|
||
import Dependencies | ||
|
||
extension StreamListener: DependencyKey { | ||
public static let liveValue: StreamListener = .live() | ||
|
||
public static func live() -> StreamListener { | ||
|
||
// 네이밍 추천 plz ., | ||
actor ContinuationActor { | ||
var continuation: AsyncStream<ServerState>.Continuation? | ||
|
||
func set(_ newContinuation: AsyncStream<ServerState>.Continuation) { | ||
continuation = newContinuation | ||
} | ||
|
||
func yield(_ state: ServerState) { | ||
continuation?.yield(state) | ||
} | ||
} | ||
|
||
let continuationActor = ContinuationActor() | ||
let asyncStream = AsyncStream<ServerState> { continuation in | ||
Task { await continuationActor.set(continuation) } | ||
} | ||
|
||
return StreamListener( | ||
sendServerState: { state in | ||
await continuationActor.yield(state) | ||
}, | ||
updateServerState: { | ||
return asyncStream | ||
} | ||
) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Projects/Core/StreamListener/Testing/StreamListenerTesting.swift
This file contains 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 @@ | ||
// | ||
// StreamListenerTesting.swift | ||
// StreamListener | ||
// | ||
// Created by <#T##Author name#> on 11/21/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct StreamListenerTesting { | ||
public init() {} | ||
} |
33 changes: 33 additions & 0 deletions
33
Projects/Core/StreamListener/Tests/StreamListenerTests.swift
This file contains 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,33 @@ | ||
// | ||
// StreamListenerTests.swift | ||
// StreamListener | ||
// | ||
// Created by <#T##Author name#> on 11/21/24. | ||
// | ||
|
||
import XCTest | ||
|
||
final class StreamListenerTests: XCTestCase { | ||
override func setUpWithError() throws { | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
} | ||
|
||
func testExample() throws { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
// Any test you write for XCTest can be annotated as throws and async. | ||
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. | ||
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. | ||
} | ||
|
||
func testPerformanceExample() throws { | ||
// This is an example of a performance test case. | ||
self.measure { | ||
// Put the code you want to measure the time of here. | ||
} | ||
} | ||
} |
This file contains 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 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
14 changes: 14 additions & 0 deletions
14
...s/Feature/ErrorFeature/Example/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains 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,14 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "ICON_DEMO.png", | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
목적에 종속되지 않도록 만드는게 좋을거 같아
Key(네트워크 에러 리스너)와 value(에러타입) 쌍으로 이루어진 dictionary를 갖게해서 (service locator 구현 하듯이)
send할때 key값과 value를 주고 receive 할때 key값을 넘겨서 그 key의 value만 옵저빙 하도록
좀 더 도움을 주자면... value에 AsyncStream을 가지고 있도록 해서 여러 stream을 지니도록 만들어서 key에 맞는 stream을 받도록 해야될거 같아
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.
이런식으로 해야 앞으로 개선해야하는 토스트 메시지, 네트워크 오프라인 유무 등에도 적용하기 좋을거 같네