diff --git a/Sources/SyncStream/SyncStream.swift b/Sources/SyncStream/SyncStream.swift index 55c3579..8d1cf0a 100644 --- a/Sources/SyncStream/SyncStream.swift +++ b/Sources/SyncStream/SyncStream.swift @@ -82,6 +82,19 @@ public class SyncStream: Sequence, IteratorProtocol { // MARK: Public + /// Constructs an synchronous stream from the Element Type + /// - Parameter type: The Element Type + /// + /// - Returns: A tuple containing the stream and its continuation. The continuation + /// should be passed to the producer while the stream should be passed to the consumer. + public static func makeStream( + of _: Element.Type = Element.self + ) -> (stream: SyncStream, continuation: SyncStream.Continuation) { + let stream = SyncStream { _ in } + let continuation = stream.continuation + return (stream, continuation) + } + public func next() -> Element? { if finished { return nil