@@ -2126,8 +2126,14 @@ extension SignalProducer {
2126
2126
2127
2127
/// Combines the values of all the given producers, in the manner described by
2128
2128
/// `combineLatest(with:)`. Will return an empty `SignalProducer` if the sequence is empty.
2129
- public static func combineLatest< S: Sequence > ( _ producers: S , noUpstreamSentinel: [ S . Iterator . Element . Value ] ? = nil ) -> SignalProducer < [ Value ] , Error > where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error {
2130
- return start ( producers, noUpstreamSentinel: noUpstreamSentinel, Signal . combineLatest)
2129
+ public static func combineLatest< S: Sequence > ( _ producers: S ) -> SignalProducer < [ Value ] , Error > where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error {
2130
+ return start ( producers, Signal . combineLatest)
2131
+ }
2132
+
2133
+ /// Combines the values of all the given producers, in the manner described by
2134
+ /// `combineLatest(with:)`. If no producer is given, the resulting producer will constantly return `emptySentinel`.
2135
+ public static func combineLatest< S: Sequence > ( _ producers: S , emptySentinel: [ S . Iterator . Element . Value ] ) -> SignalProducer < [ Value ] , Error > where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error {
2136
+ return start ( producers, emptySentinel: emptySentinel, Signal . combineLatest)
2131
2137
}
2132
2138
2133
2139
/// Zips the values of all the given producers, in the manner described by
@@ -2204,21 +2210,33 @@ extension SignalProducer {
2204
2210
2205
2211
/// Zips the values of all the given producers, in the manner described by
2206
2212
/// `zipWith`. Will return an empty `SignalProducer` if the sequence is empty.
2207
- public static func zip< S: Sequence > ( _ producers: S , noUpstreamSentinel: [ S . Iterator . Element . Value ] ? = nil ) -> SignalProducer < [ Value ] , Error > where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error {
2208
- return start ( producers, noUpstreamSentinel: noUpstreamSentinel, Signal . zip)
2213
+ public static func zip< S: Sequence > ( _ producers: S ) -> SignalProducer < [ Value ] , Error > where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error {
2214
+ return start ( producers, Signal . zip)
2215
+ }
2216
+
2217
+ /// Combines the values of all the given producers, in the manner described by
2218
+ /// `zip(with:)`. If no producer is given, the resulting producer will constantly return `emptySentinel`.
2219
+ public static func zip< S: Sequence > ( _ producers: S , emptySentinel: [ S . Iterator . Element . Value ] ) -> SignalProducer < [ Value ] , Error > where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error {
2220
+ return start ( producers, emptySentinel: emptySentinel, Signal . zip)
2209
2221
}
2210
2222
2211
- private static func start< S: Sequence > ( _ producers: S , noUpstreamSentinel: [ S . Iterator . Element . Value ] ? , _ transform: @escaping ( AnySequence < Signal < Value , Error > > ) -> Signal < [ Value ] , Error > ) -> SignalProducer < [ Value ] , Error > where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error
2223
+ private static func start< S: Sequence > (
2224
+ _ producers: S ,
2225
+ emptySentinel: [ S . Iterator . Element . Value ] ? = nil ,
2226
+ _ transform: @escaping ( AnySequence < Signal < Value , Error > > ) -> Signal < [ Value ] , Error >
2227
+ ) -> SignalProducer < [ Value ] , Error >
2228
+ where S. Iterator. Element: SignalProducerConvertible , S. Iterator. Element. Value == Value , S. Iterator. Element. Error == Error
2212
2229
{
2213
2230
return SignalProducer < [ Value ] , Error > { observer, lifetime in
2214
2231
let setup = producers. map {
2215
2232
( producer: $0. producer, pipe: Signal< Value, Error> . pipe( ) )
2216
2233
}
2217
2234
2218
2235
guard !setup. isEmpty else {
2219
- if let noUpstreamSentinel = noUpstreamSentinel {
2220
- observer. send ( value: noUpstreamSentinel)
2221
- }
2236
+ if let emptySentinel = emptySentinel {
2237
+ observer. send ( value: emptySentinel)
2238
+ }
2239
+
2222
2240
observer. sendCompleted ( )
2223
2241
return
2224
2242
}
@@ -2743,12 +2761,14 @@ extension SignalProducer where Value == Bool {
2743
2761
2744
2762
/// Create a producer that computes a logical AND between the latest values of `booleans`.
2745
2763
///
2764
+ /// If no producer is given in `booleans`, the resulting producer constantly emits `true`.
2765
+ ///
2746
2766
/// - parameters:
2747
2767
/// - booleans: A collection of boolean producers to be combined.
2748
2768
///
2749
2769
/// - returns: A producer that emits the logical AND results.
2750
2770
public static func all< BooleansCollection: Collection > ( _ booleans: BooleansCollection ) -> SignalProducer < Value , Error > where BooleansCollection. Element == SignalProducer < Value , Error > {
2751
- return combineLatest ( booleans, noUpstreamSentinel : [ ] ) . map { $0. reduce ( true ) { $0 && $1 } }
2771
+ return combineLatest ( booleans, emptySentinel : [ ] ) . map { $0. reduce ( true ) { $0 && $1 } }
2752
2772
}
2753
2773
2754
2774
/// Create a producer that computes a logical AND between the latest values of `booleans`.
@@ -2785,16 +2805,20 @@ extension SignalProducer where Value == Bool {
2785
2805
2786
2806
/// Create a producer that computes a logical OR between the latest values of `booleans`.
2787
2807
///
2808
+ /// If no producer is given in `booleans`, the resulting producer constantly emits `true`.
2809
+ ///
2788
2810
/// - parameters:
2789
2811
/// - booleans: A collection of boolean producers to be combined.
2790
2812
///
2791
2813
/// - returns: A producer that emits the logical OR results.
2792
2814
public static func any< BooleansCollection: Collection > ( _ booleans: BooleansCollection ) -> SignalProducer < Value , Error > where BooleansCollection. Element == SignalProducer < Value , Error > {
2793
- return combineLatest ( booleans, noUpstreamSentinel : [ ] ) . map { $0. reduce ( false ) { $0 || $1 } }
2815
+ return combineLatest ( booleans, emptySentinel : [ ] ) . map { $0. reduce ( false ) { $0 || $1 } }
2794
2816
}
2795
2817
2796
2818
/// Create a producer that computes a logical OR between the latest values of `booleans`.
2797
2819
///
2820
+ /// If no producer is given in `booleans`, the resulting producer constantly emits `true`.
2821
+ ///
2798
2822
/// - parameters:
2799
2823
/// - booleans: A collection of boolean producers to be combined.
2800
2824
///
0 commit comments