@@ -236,6 +236,52 @@ public struct SignalProducer<Value, Error: Swift.Error> {
236236 }
237237}
238238
239+ extension SignalProducer where Error == NoError {
240+ /// Creates a producer for a `Signal` that will immediately send one value
241+ /// then complete.
242+ ///
243+ /// - parameters:
244+ /// - value: A value that should be sent by the `Signal` in a `value`
245+ /// event.
246+ public init ( value: Value ) {
247+ self . init { observer, _ in
248+ observer. send ( value: value)
249+ observer. sendCompleted ( )
250+ }
251+ }
252+
253+ /// Creates a producer for a Signal that will immediately send the values
254+ /// from the given sequence, then complete.
255+ ///
256+ /// - parameters:
257+ /// - values: A sequence of values that a `Signal` will send as separate
258+ /// `value` events and then complete.
259+ public init < S: Sequence > ( _ values: S ) where S. Iterator. Element == Value {
260+ self . init { observer, lifetime in
261+ for value in values {
262+ observer. send ( value: value)
263+
264+ if lifetime. hasEnded {
265+ break
266+ }
267+ }
268+
269+ observer. sendCompleted ( )
270+ }
271+ }
272+
273+ /// Creates a producer for a Signal that will immediately send the values
274+ /// from the given sequence, then complete.
275+ ///
276+ /// - parameters:
277+ /// - first: First value for the `Signal` to send.
278+ /// - second: Second value for the `Signal` to send.
279+ /// - tail: Rest of the values to be sent by the `Signal`.
280+ public init ( values first: Value , _ second: Value , _ tail: Value ... ) {
281+ self . init ( [ first, second ] + tail)
282+ }
283+ }
284+
239285extension SignalProducer where Error == AnyError {
240286 /// Create a `SignalProducer` that will attempt the given failable operation once for
241287 /// each invocation of `start()`.
0 commit comments