-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
80 additions
and
53 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
Projects/Core/StreamListener/Interface/AnyStreamContinuation.swift
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
Projects/Core/StreamListener/Interface/StreamContinuation.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,25 @@ | ||
import Foundation | ||
|
||
public class StreamContinuation { | ||
private let _yield: (any StreamType) -> Void | ||
private let _finish: () -> Void | ||
|
||
public init<T: StreamType>(_ continuation: AsyncStream<T>.Continuation) { | ||
self._yield = { value in | ||
guard let value = value as? T else { return } | ||
continuation.yield(value) | ||
} | ||
|
||
self._finish = { | ||
continuation.finish() | ||
} | ||
} | ||
|
||
public func yield(_ value: any StreamType) { | ||
_yield(value) | ||
} | ||
|
||
public func finish() { | ||
_finish() | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
22 changes: 22 additions & 0 deletions
22
Projects/Domain/AppService/Sources/ServerStateStream.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,22 @@ | ||
// | ||
// ServerStateStream.swift | ||
// AppService | ||
// | ||
// Created by 김지현 on 12/25/24. | ||
// Copyright © 2024 PomoNyang. All rights reserved. | ||
// | ||
|
||
import StreamListenerInterface | ||
|
||
public enum ServerState: StreamType { | ||
public static var key: StreamKey { "serverState" } | ||
case requestStarted | ||
case requestCompleted | ||
case errorOccured | ||
case networkDisabled | ||
} | ||
|
||
public struct RetryState: StreamType { | ||
public static var key: StreamKey { "retryState" } | ||
public var retry: Int? | ||
} |
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