Skip to content

Commit

Permalink
feat(BidrectionalSyncStream): add method makeStream(of:) (#2)
Browse files Browse the repository at this point in the history
* feat(BidrectionalSyncStream): add method `makeStream(of:)`

* doc(BidrectionalSyncStream): add doc for method `makeStream(of:)`
  • Loading branch information
rockmagma02 authored Apr 21, 2024
1 parent b58306c commit c686681
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/SyncStream/BidirectionalSyncStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,18 @@ public extension BidirectionalSyncStream {
}
}
}

/// Constructs an Bidrectional synchronous stream from 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.
static func makeStream(
_: YieldT.Type = YieldT.self,
_: SendT.Type = SendT.self,
_: ReturnT.Type = ReturnT.self
) -> (stream: BidirectionalSyncStream<YieldT, SendT, ReturnT>, continuation: BidirectionalSyncStream<YieldT, SendT, ReturnT>.Continuation) {
let stream = BidirectionalSyncStream { _ in }
let continuation = stream.continuation
return (stream, continuation)
}
}

0 comments on commit c686681

Please sign in to comment.