SignalProducer
public struct SignalProducer<Value, Error> where Error : Error
extension SignalProducer: SignalProducerConvertible, SignalProducerProtocol
extension SignalProducer: BindingSource where Error == Never
A SignalProducer creates Signals that can produce values of type Value
and/or fail with errors of type Error. If no failure should be possible,
Never can be specified for Error.
SignalProducers can be used to represent operations or tasks, like network
requests, where each invocation of start() will create a new underlying
operation. This ensures that consumers will receive the results, versus a
plain Signal, where the results might be sent before any observers are
attached.
Because of the behavior of start(), different Signals created from the
producer may see a different version of Events. The Events may arrive in a
different order between Signals, or the stream might be completely
different!
-
Convert an entity into its equivalent representation as
SignalProducer.Declaration
Swift
public init<T>(_ base: T) where Value == T.Value, Error == T.Error, T : SignalProducerConvertibleParameters
baseThe entity to convert from.
-
Initializes a
SignalProducerthat will emit the same events as the given signal.If the Disposable returned from
start()is disposed or a terminating event is sent to the observer, the given signal will be disposed.Declaration
Swift
public init(_ signal: Signal<Value, Error>)Parameters
signalA signal to observe after starting the producer.
-
Initialize a
SignalProducerwhich invokes the supplied starting side effect once upon the creation of every producedSignal, or in other words, for every invocation ofstartWithSignal(_:),start(_:)and their convenience shorthands.The supplied starting side effect would be given (1) an input
Observerto emit events to the producedSignal; and (2) aLifetimeto bind resources to the lifetime of the producedSignal.The
Lifetimeof a producedSignalends when: (1) a terminal event is sent to the inputObserver; or (2) when the producedSignalis interrupted via the disposable yielded at the starting call.Declaration
Parameters
startHandlerThe starting side effect.
-
Creates a producer for a
Signalthat immediately sends one value, then completes.This initializer differs from
init(value:)in that its solevalueevent is constructed lazily by invoking the suppliedactionwhen theSignalProduceris started.Declaration
Swift
public init(_ action: @escaping () -> Value)Parameters
actionA action that yields a value to be sent by the
Signalas avalueevent. -
Create a
SignalProducerthat will attempt the given operation once for each invocation ofstart().Upon success, the started signal will send the resulting value then complete. Upon failure, the started signal will fail with the error that occurred.
Declaration
Swift
public init(_ action: @escaping () -> Result<Value, Error>)Parameters
actionA closure that returns instance of
Result. -
Creates a producer for a Signal that will immediately send one value then complete, or immediately fail, depending on the given Result.
Declaration
Swift
public init(result: Result<Value, Error>)Parameters
resultA
Resultinstance that will send eithervalueevent ifresultissuccessful orfailedevent ifresultis afailure. -
Creates a producer for a Signal that will immediately send the values from the given sequence, then complete.
Declaration
Swift
public init<S>(_ values: S) where Value == S.Element, S : SequenceParameters
valuesA sequence of values that a
Signalwill send as separatevalueevents and then complete. -
Creates a producer for a Signal that will immediately send the values from the given sequence, then complete.
Declaration
Swift
public init(values first: Value, _ second: Value, _ tail: Value...) -
A producer for a Signal that immediately completes without sending any values.
Declaration
Swift
public static var empty: SignalProducer { get } -
A producer for a Signal that never sends any events to its observers.
Declaration
Swift
public static var never: SignalProducer { get } -
Create a
Signalfromself, pass it into the given closure, and start the associated work on the producedSignalas the closure returns.Declaration
Swift
@discardableResult public func startWithSignal<Result>(_ setup: (_ signal: Signal<Value, Error>, _ interruptHandle: Disposable) -> Result) -> ResultParameters
setupReturn Value
The return value of the given setup closure.
-
Logs all events that the receiver sends. By default, it will print to the standard output.
Declaration
Swift
public func logEvents(identifier: String = "", events: Set<LoggingEvent.SignalProducer> = LoggingEvent.SignalProducer.allEvents, fileName: String = #file, functionName: String = #function, lineNumber: Int = #line, logger: @escaping EventLogger = defaultEventLog ) -> SignalProducer<Value, Error>Parameters
identifiera string to identify the SignalProducer firing events.
eventsTypes of events to log.
fileNameName of the file containing the code which fired the event.
functionNameFunction where event was fired.
lineNumberLine number where event was fired.
loggerLogger that logs the events.
Return Value
Signal producer that, when started, logs the fired events.
-
concatsnextontoself.Declaration
Swift
public func concat(_ next: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>Parameters
nextA follow-up producer to concat
selfwith.Return Value
A producer that will start
selfand then on completion ofself- will startnext. -
concatsnextontoself.Declaration
Swift
public func concat<Next>(_ next: Next) -> SignalProducer<Value, Error> where Value == Next.Value, Error == Next.Error, Next : SignalProducerConvertibleParameters
nextA follow-up producer to concat
selfwith.Return Value
A producer that will start
selfand then on completion ofself- will startnext. -
concatsvalueontoself.Declaration
Swift
public func concat(value: Value) -> SignalProducer<Value, Error>Parameters
valueA value to concat onto
self.Return Value
A producer that, when started, will emit own values and on completion will emit a
value. -
concatserrorontoself.Declaration
Swift
public func concat(error: Error) -> SignalProducer<Value, Error>Parameters
errorAn error to concat onto
self.Return Value
A producer that, when started, will emit own values and on completion will emit an
error. -
concatsselfonto initialprevious.Declaration
Swift
public func prefix(_ previous: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>Parameters
previousA producer to start before
self.Return Value
A signal producer that, when started, first emits values from
previousproducer and then fromself. -
concatsselfonto initialprevious.Declaration
Swift
public func prefix<Previous>(_ previous: Previous) -> SignalProducer<Value, Error> where Value == Previous.Value, Error == Previous.Error, Previous : SignalProducerConvertibleParameters
previousA producer to start before
self.Return Value
A signal producer that, when started, first emits values from
previousproducer and then fromself. -
concatsselfonto initialvalue.Declaration
Swift
public func prefix(value: Value) -> SignalProducer<Value, Error>Parameters
valueA first value to emit.
Return Value
A producer that, when started, first emits
value, then all values emited byself. -
Merges the given producers into a single
SignalProducerthat will emit all values from each of them, and complete when all of them have completed.Declaration
Swift
public static func merge<Seq>(_ producers: Seq) -> SignalProducer<Value, Error> where Seq : Sequence, Seq.Element == SignalProducer<Value, Error>Parameters
producersA sequence of producers to merge.
-
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B>(_ a: A, _ b: B) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C>(_ a: A, _ b: B, _ c: C) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C, D>(_ a: A, _ b: B, _ c: C, _ d: D) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value, C.Error == D.Error, C.Value == D.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C, D, E>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value, C.Error == D.Error, C.Value == D.Value, D.Error == E.Error, D.Value == E.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C, D, E, F>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value, C.Error == D.Error, C.Value == D.Value, D.Error == E.Error, D.Value == E.Value, E.Error == F.Error, E.Value == F.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C, D, E, F, G>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value, C.Error == D.Error, C.Value == D.Value, D.Error == E.Error, D.Value == E.Value, E.Error == F.Error, E.Value == F.Value, F.Error == G.Error, F.Value == G.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C, D, E, F, G, H>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value, C.Error == D.Error, C.Value == D.Value, D.Error == E.Error, D.Value == E.Value, E.Error == F.Error, E.Value == F.Value, F.Error == G.Error, F.Value == G.Value, G.Error == H.Error, G.Value == H.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C, D, E, F, G, H, I>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, I : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value, C.Error == D.Error, C.Value == D.Value, D.Error == E.Error, D.Value == E.Value, E.Error == F.Error, E.Value == F.Value, F.Error == G.Error, F.Value == G.Value, G.Error == H.Error, G.Value == H.Value, H.Error == I.Error, H.Value == I.Value -
Merge the values of all the given producers, in the manner described by
merge(_:).Declaration
Swift
public static func merge<A, B, C, D, E, F, G, H, I, J>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I, _ j: J) -> SignalProducer<Value, Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, I : SignalProducerConvertible, J : SignalProducerConvertible, A.Error == B.Error, A.Value == B.Value, B.Error == C.Error, B.Value == C.Value, C.Error == D.Error, C.Value == D.Value, D.Error == E.Error, D.Value == E.Value, E.Error == F.Error, E.Value == F.Value, F.Error == G.Error, F.Value == G.Value, G.Error == H.Error, G.Value == H.Value, H.Error == I.Error, H.Value == I.Value, I.Error == J.Error, I.Value == J.Value -
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
selfor any of the created producers fail, the returned producer will forward that failure immediately.Declaration
Swift
public func flatMap<U>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> SignalProducer<U, Error>) -> SignalProducer<U, Error>Parameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
selfor any of the created producers fail, the returned producer will forward that failure immediately.Declaration
Swift
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Error> where Inner.Error == ErrorParameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
selffails, the returned producer will forward that failure immediately.Declaration
Swift
public func flatMap<U>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> SignalProducer<U, Never>) -> SignalProducer<U, Error>Parameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
selffails, the returned producer will forward that failure immediately.Declaration
Swift
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Error> where Inner.Error == NeverParameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Catches any failure that may occur on the input producer, mapping to a new producer that starts in its place.
Declaration
Swift
public func flatMapError<F>(_ transform: @escaping (Error) -> SignalProducer<Value, F>) -> SignalProducer<Value, F>Parameters
transformA closure that accepts emitted error and returns a signal producer with a different type of error.
-
Catches any failure that may occur on the input producer, mapping to a new producer that starts in its place.
Declaration
Swift
public func flatMapError<Inner: SignalProducerConvertible>(_ transform: @escaping (Error) -> Inner) -> SignalProducer<Value, Inner.Error> where Inner.Value == ValueParameters
transformA closure that accepts emitted error and returns a signal producer with a different type of error.
-
Declaration
Swift
public var producer: SignalProducer { get } -
Create a
Signalfromself, and observe it with the given observer.Declaration
Swift
@discardableResult public func start(_ observer: Signal<Value, Error>.Observer = .init()) -> DisposableParameters
observerAn observer to attach to the produced
Signal.Return Value
A disposable to interrupt the produced
Signal. -
Declaration
Swift
@discardableResult public func start(_ action: @escaping Signal<Value, Error>.Observer.Action) -> DisposableParameters
actionA closure to be invoked with every event from
self.Return Value
A disposable to interrupt the produced
Signal. -
Create a
Signalfromself, and observe theSignalfor all values being emitted, and if any, its failure.Declaration
Swift
@discardableResult public func startWithResult(_ action: @escaping (Result<Value, Error>) -> Void) -> DisposableParameters
actionA closure to be invoked with values from
self, or the propagated error should anyfailedevent is emitted.Return Value
A disposable to interrupt the produced
Signal. -
Create a
Signalfromself, and observe its completion.Declaration
Swift
@discardableResult public func startWithCompleted(_ action: @escaping () -> Void) -> DisposableParameters
actionA closure to be invoked when a
completedevent is emitted.Return Value
A disposable to interrupt the produced
Signal. -
Create a
Signalfromself, and observe its failure.Declaration
Swift
@discardableResult public func startWithFailed(_ action: @escaping (Error) -> Void) -> DisposableParameters
actionA closure to be invoked with the propagated error, should any
failedevent is emitted.Return Value
A disposable to interrupt the produced
Signal. -
Create a
Signalfromself, and observe its interruption.Declaration
Swift
@discardableResult public func startWithInterrupted(_ action: @escaping () -> Void) -> DisposableParameters
actionA closure to be invoked when an
interruptedevent is emitted.Return Value
A disposable to interrupt the produced
Signal. -
Lift an unary Signal operator to operate upon SignalProducers instead.
In other words, this will create a new
SignalProducerwhich will apply the givenSignaloperator to every createdSignal, just as if the operator had been applied to eachSignalyielded fromstart().Declaration
Parameters
transformAn unary operator to lift.
Return Value
A signal producer that applies signal’s operator to every created signal.
-
Lift a binary Signal operator to operate upon SignalProducers instead.
In other words, this will create a new
SignalProducerwhich will apply the givenSignaloperator to everySignalcreated from the two producers, just as if the operator had been applied to eachSignalyielded fromstart().Note
starting the returned producer will start the receiver of the operator, which may not be adviseable for some operators.
Declaration
Parameters
transformA binary operator to lift.
Return Value
A binary operator that operates on two signal producers.
-
Map each value in the producer to a new value.
Declaration
Swift
public func map<U>(_ transform: @escaping (Value) -> U) -> SignalProducer<U, Error>Parameters
transformA closure that accepts a value and returns a different value.
Return Value
A signal producer that, when started, will send a mapped value of
self. -
Map each value in the producer to a new constant value.
Declaration
Swift
public func map<U>(value: U) -> SignalProducer<U, Error>Parameters
valueA new value.
Return Value
A signal producer that, when started, will send a mapped value of
self. -
Map each value in the producer to a new value by applying a key path.
Declaration
Swift
public func map<U>(_ keyPath: KeyPath<Value, U>) -> SignalProducer<U, Error>Parameters
keyPathA key path relative to the producer’s
Valuetype.Return Value
A producer that will send new values.
-
Map errors in the producer to a new error.
Declaration
Swift
public func mapError<F>(_ transform: @escaping (Error) -> F) -> SignalProducer<Value, F>Parameters
transformA closure that accepts an error object and returns a different error.
Return Value
A producer that emits errors of new type.
-
Maps each value in the producer to a new value, lazily evaluating the supplied transformation on the specified scheduler.
Important
Unlike
map, there is not a 1-1 mapping between incoming values, and values sent on the returned producer. Ifschedulerhas not yet scheduledtransformfor execution, then each new value will replace the last one as the parameter totransformonce it is finally executed.Declaration
Swift
public func lazyMap<U>(on scheduler: Scheduler, transform: @escaping (Value) -> U) -> SignalProducer<U, Error>Parameters
transformThe closure used to obtain the returned value from this producer’s underlying value.
Return Value
A producer that, when started, sends values obtained using
transformas this producer sends values. -
Preserve only values which pass the given closure.
Declaration
Swift
public func filter(_ isIncluded: @escaping (Value) -> Bool) -> SignalProducer<Value, Error>Parameters
isIncludedA closure to determine whether a value from
selfshould be included in the producedSignal.Return Value
A producer that, when started, forwards the values passing the given closure.
-
Applies
transformto values from the producer and forwards values with nonnilresults unwrapped.Declaration
Swift
public func compactMap<U>(_ transform: @escaping (Value) -> U?) -> SignalProducer<U, Error>Parameters
transformA closure that accepts a value from the
valueevent and returns a new optional value.Return Value
A producer that will send new values, that are non
nilafter the transformation. -
Applies
transformto values from the producer and forwards values with nonnilresults unwrapped.Declaration
Swift
@available(*, deprecated, renamed: "compactMap") public func filterMap<U>(_ transform: @escaping (Value) -> U?) -> SignalProducer<U, Error>Parameters
transformA closure that accepts a value from the
valueevent and returns a new optional value.Return Value
A producer that will send new values, that are non
nilafter the transformation. -
Yield the first
countvalues from the input producer.Precondition
countmust be non-negative number.Declaration
Swift
public func take(first count: Int) -> SignalProducer<Value, Error>Parameters
countA number of values to take from the signal.
Return Value
A producer that, when started, will yield the first
countvalues fromself. -
Yield an array of values when
selfcompletes.Note
When
selfcompletes without collecting any value, it will send an empty array of values.Declaration
Swift
public func collect() -> SignalProducer<[Value], Error>Return Value
A producer that, when started, will yield an array of values when
selfcompletes. -
Yield an array of values until it reaches a certain count.
Precondition
countmust be greater than zero.Note
When the count is reached the array is sent and the signal starts over yielding a new array of values.
Note
When
selfcompletes any remaining values will be sent, the last array may not havecountvalues. Alternatively, if were not collected any values will sent an empty array of values.Declaration
Swift
public func collect(count: Int) -> SignalProducer<[Value], Error>Return Value
A producer that, when started, collects at most
countvalues fromself, forwards them as a single array and completes. -
Collect values from
self, and emit them if the predicate passes.When
selfcompletes any remaining values will be sent, regardless of the collected values matchingshouldEmitor not.If
selfcompletes without having emitted any value, an empty array would be emitted, followed by the completion of the producedSignal.let (producer, observer) = SignalProducer<Int, Never>.buffer(1) producer .collect { values in values.reduce(0, combine: +) == 8 } .startWithValues { print($0) } observer.send(value: 1) observer.send(value: 3) observer.send(value: 4) observer.send(value: 7) observer.send(value: 1) observer.send(value: 5) observer.send(value: 6) observer.sendCompleted() // Output: // [1, 3, 4] // [7, 1] // [5, 6]Declaration
Swift
public func collect(_ shouldEmit: @escaping (_ values: [Value]) -> Bool) -> SignalProducer<[Value], Error>Parameters
shouldEmitA closure to determine, when every time a new value is received, whether the collected values should be emitted.
Return Value
A producer of arrays of values, as instructed by the
shouldEmitclosure. -
Collect values from
self, and emit them if the predicate passes.When
selfcompletes any remaining values will be sent, regardless of the collected values matchingshouldEmitor not.If
selfcompletes without having emitted any value, an empty array would be emitted, followed by the completion of the producedSignal.let (producer, observer) = SignalProducer<Int, Never>.buffer(1) producer .collect { values, value in value == 7 } .startWithValues { print($0) } observer.send(value: 1) observer.send(value: 1) observer.send(value: 7) observer.send(value: 7) observer.send(value: 5) observer.send(value: 6) observer.sendCompleted() // Output: // [1, 1] // [7] // [7, 5, 6]Declaration
Swift
public func collect(_ shouldEmit: @escaping (_ collected: [Value], _ latest: Value) -> Bool) -> SignalProducer<[Value], Error>Parameters
shouldEmitA closure to determine, when every time a new value is received, whether the collected values should be emitted. The new value is not included in the collected values, and is included when the next value is received.
Return Value
A producer of arrays of values, as instructed by the
shouldEmitclosure. -
Forward the latest values on
schedulereveryinterval.Note
If
selfterminates while values are being accumulated, the behaviour will be determined bydiscardWhenCompleted. Iftrue, the values will be discarded and the returned producer will terminate immediately. Iffalse, that values will be delivered at the next interval.Declaration
Swift
public func collect(every interval: DispatchTimeInterval, on scheduler: DateScheduler, skipEmpty: Bool = false, discardWhenCompleted: Bool = true) -> SignalProducer<[Value], Error>Parameters
intervalA repetition interval.
schedulerA scheduler to send values on.
skipEmptyWhether empty arrays should be sent if no values were accumulated during the interval.
discardWhenCompletedA boolean to indicate if the latest unsent values should be discarded on completion.
Return Value
A producer that sends all values that are sent from
selfatintervalseconds apart. -
Forward all events onto the given scheduler, instead of whichever scheduler they originally arrived upon.
Declaration
Swift
public func observe(on scheduler: Scheduler) -> SignalProducer<Value, Error>Parameters
schedulerA scheduler to deliver events on.
Return Value
A producer that, when started, will yield
selfvalues on provided scheduler. -
Combine the latest value of the receiver with the latest value from the given producer.
Note
The returned producer will not send a value until both inputs have sent at least one value each.
Note
If either producer is interrupted, the returned producer will also be interrupted.
Note
The returned producer will not complete until both inputs complete.
Declaration
Swift
public func combineLatest<U>(with other: SignalProducer<U, Error>) -> SignalProducer<(Value, U), Error>Parameters
otherA producer to combine
self‘s value with.Return Value
A producer that, when started, will yield a tuple containing values of
selfand given producer. -
Combine the latest value of the receiver with the latest value from the given producer.
Note
The returned producer will not send a value until both inputs have sent at least one value each.
Note
If either producer is interrupted, the returned producer will also be interrupted.
Note
The returned producer will not complete until both inputs complete.
Declaration
Swift
public func combineLatest<Other>(with other: Other) -> SignalProducer<(Value, Other.Value), Error> where Error == Other.Error, Other : SignalProducerConvertibleParameters
otherA producer to combine
self‘s value with.Return Value
A producer that, when started, will yield a tuple containing values of
selfand given producer. -
Merge the given producer into a single
SignalProducerthat will emit all values from both of them, and complete when all of them have completed.Declaration
Swift
public func merge(with other: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>Parameters
otherA producer to merge
self‘s value with.Return Value
A producer that sends all values of
selfand given producer. -
Merge the given producer into a single
SignalProducerthat will emit all values from both of them, and complete when all of them have completed.Declaration
Swift
public func merge<Other>(with other: Other) -> SignalProducer<Value, Error> where Value == Other.Value, Error == Other.Error, Other : SignalProducerConvertibleParameters
otherA producer to merge
self‘s value with.Return Value
A producer that sends all values of
selfand given producer. -
Delay
valueandcompletedevents by the given interval, forwarding them on the given scheduler.Note
failedandinterruptedevents are always scheduled immediately.Declaration
Swift
public func delay(_ interval: TimeInterval, on scheduler: DateScheduler) -> SignalProducer<Value, Error>Parameters
intervalInterval to delay
valueandcompletedevents by.schedulerA scheduler to deliver delayed events on.
Return Value
A producer that, when started, will delay
valueandcompletedevents and will yield them on given scheduler. -
Skip the first
countvalues, then forward everything afterward.Declaration
Swift
public func skip(first count: Int) -> SignalProducer<Value, Error>Parameters
countA number of values to skip.
Return Value
A producer that, when started, will skip the first
countvalues, then forward everything afterward. -
Treats all Events from the input producer as plain values, allowing them to be manipulated just like any other value.
In other words, this brings Events “into the monad.”
Note
When a Completed or Failed event is received, the resulting producer will send the Event itself and then complete. When an
interruptedevent is received, the resulting producer will send theEventitself and then interrupt.Declaration
Swift
public func materialize() -> SignalProducer<ProducedSignal.Event, Never>Return Value
A producer that sends events as its values.
-
Treats all Results from the input producer as plain values, allowing them to be manipulated just like any other value.
In other words, this brings Results “into the monad.”
Note
When a Failed event is received, the resulting producer will send the
Result.failureitself and then complete.Declaration
Swift
public func materializeResults() -> SignalProducer<Result<Value, Error>, Never>Return Value
A producer that sends results as its values.
-
Forward the latest value from
selfwith the value fromsampleras a tuple, only whensamplersends avalueevent.Note
If
samplerfires before a value has been observed onself, nothing happens.Declaration
Swift
public func sample<U>(with sampler: SignalProducer<U, Never>) -> SignalProducer<(Value, U), Error>Parameters
samplerA producer that will trigger the delivery of
valueevent fromself.Return Value
A producer that will send values from
selfandsampler, sampled (possibly multiple times) bysampler, then complete once both input producers have completed, or interrupt if either input producer is interrupted. -
Forward the latest value from
selfwith the value fromsampleras a tuple, only whensamplersends avalueevent.Note
If
samplerfires before a value has been observed onself, nothing happens.Declaration
Swift
public func sample<Sampler>(with sampler: Sampler) -> SignalProducer<(Value, Sampler.Value), Error> where Sampler : SignalProducerConvertible, Sampler.Error == NeverParameters
samplerA producer that will trigger the delivery of
valueevent fromself.Return Value
A producer that will send values from
selfandsampler, sampled (possibly multiple times) bysampler, then complete once both input producers have completed, or interrupt if either input producer is interrupted. -
Forward the latest value from
selfwheneversamplersends avalueevent.Note
If
samplerfires before a value has been observed onself, nothing happens.Declaration
Swift
public func sample(on sampler: SignalProducer<(), Never>) -> SignalProducer<Value, Error>Parameters
samplerA producer that will trigger the delivery of
valueevent fromself.Return Value
A producer that, when started, will send values from
self, sampled (possibly multiple times) bysampler, then complete once both input producers have completed, or interrupt if either input producer is interrupted. -
Forward the latest value from
selfwheneversamplersends avalueevent.Note
If
samplerfires before a value has been observed onself, nothing happens.Declaration
Swift
public func sample<Sampler>(on sampler: Sampler) -> SignalProducer<Value, Error> where Sampler : SignalProducerConvertible, Sampler.Error == Never, Sampler.Value == ()Parameters
samplerA producer that will trigger the delivery of
valueevent fromself.Return Value
A producer that, when started, will send values from
self, sampled (possibly multiple times) bysampler, then complete once both input producers have completed, or interrupt if either input producer is interrupted. -
Forward the latest value from
sampleewith the value fromselfas a tuple, only whenselfsends avalueevent. This is like a flipped version ofsample(with:), butsamplee‘s terminal events are completely ignored.Note
If
selffires before a value has been observed onsamplee, nothing happens.Declaration
Swift
public func withLatest<U>(from samplee: SignalProducer<U, Never>) -> SignalProducer<(Value, U), Error>Parameters
sampleeA producer whose latest value is sampled by
self.Return Value
A producer that will send values from
selfandsamplee, sampled (possibly multiple times) byself, then terminate onceselfhas terminated.samplee‘s terminated events are ignored. -
Forward the latest value from
sampleewith the value fromselfas a tuple, only whenselfsends avalueevent. This is like a flipped version ofsample(with:), butsamplee‘s terminal events are completely ignored.Note
If
selffires before a value has been observed onsamplee, nothing happens.Declaration
Swift
public func withLatest<Samplee>(from samplee: Samplee) -> SignalProducer<(Value, Samplee.Value), Error> where Samplee : SignalProducerConvertible, Samplee.Error == NeverParameters
sampleeA producer whose latest value is sampled by
self.Return Value
A producer that will send values from
selfandsamplee, sampled (possibly multiple times) byself, then terminate onceselfhas terminated.samplee‘s terminated events are ignored. -
Forwards events from
selfuntillifetimeends, at which point the returned producer will complete.Declaration
Swift
public func take(during lifetime: Lifetime) -> SignalProducer<Value, Error>Parameters
lifetimeA lifetime whose
endedsignal will cause the returned producer to complete.Return Value
A producer that will deliver events until
lifetimeends. -
Forward events from
selfuntiltriggersends avalueorcompletedevent, at which point the returned producer will complete.Declaration
Swift
public func take(until trigger: SignalProducer<(), Never>) -> SignalProducer<Value, Error>Parameters
triggerA producer whose
valueorcompletedevents will stop the delivery ofvalueevents fromself.Return Value
A producer that will deliver events until
triggersendsvalueorcompletedevents. -
Forward events from
selfuntiltriggersends avalueorcompletedevent, at which point the returned producer will complete.Declaration
Swift
public func take<Trigger>(until trigger: Trigger) -> SignalProducer<Value, Error> where Trigger : SignalProducerConvertible, Trigger.Error == Never, Trigger.Value == ()Parameters
triggerA producer whose
valueorcompletedevents will stop the delivery ofvalueevents fromself.Return Value
A producer that will deliver events until
triggersendsvalueorcompletedevents. -
Do not forward any values from
selfuntiltriggersends avalueorcompleted, at which point the returned producer behaves exactly likeproducer.Declaration
Swift
public func skip(until trigger: SignalProducer<(), Never>) -> SignalProducer<Value, Error>Parameters
triggerA producer whose
valueorcompletedevents will start the deliver of events onself.Return Value
A producer that will deliver events once the
triggersendsvalueorcompletedevents. -
Do not forward any values from
selfuntiltriggersends avalueorcompleted, at which point the returned producer behaves exactly likeproducer.Declaration
Swift
public func skip<Trigger>(until trigger: Trigger) -> SignalProducer<Value, Error> where Trigger : SignalProducerConvertible, Trigger.Error == Never, Trigger.Value == ()Parameters
triggerA producer whose
valueorcompletedevents will start the deliver of events onself.Return Value
A producer that will deliver events once the
triggersendsvalueorcompletedevents. -
Forward events from
selfwith history: values of the returned producer are a tuples whose first member is the previous value and whose second member is the current value.initialis supplied as the first member whenselfsends its first value.Declaration
Swift
public func combinePrevious(_ initial: Value) -> SignalProducer<(Value, Value), Error>Parameters
initialA value that will be combined with the first value sent by
self.Return Value
A producer that sends tuples that contain previous and current sent values of
self. -
Forward events from
selfwith history: values of the produced signal are a tuples whose first member is the previous value and whose second member is the current value.The produced
Signalwould not emit any tuple until it has received at least two values.Declaration
Swift
public func combinePrevious() -> SignalProducer<(Value, Value), Error>Return Value
A producer that sends tuples that contain previous and current sent values of
self. -
Combine all values from
self, and forward the final result.See
scan(_:_:)if the resulting producer needs to forward also the partial results.Declaration
Swift
public func reduce<U>(_ initialResult: U, _ nextPartialResult: @escaping (U, Value) -> U) -> SignalProducer<U, Error>Parameters
initialResultThe value to use as the initial accumulating value.
nextPartialResultA closure that combines the accumulating value and the latest value from
self. The result would be used in the next call ofnextPartialResult, or emit to the returnedSignalwhenselfcompletes.Return Value
A producer that sends the final result as
selfcompletes. -
Combine all values from
self, and forward the final result.See
scan(into:_:)if the resulting producer needs to forward also the partial results.Declaration
Swift
public func reduce<U>(into initialResult: U, _ nextPartialResult: @escaping (inout U, Value) -> Void) -> SignalProducer<U, Error>Parameters
initialResultThe value to use as the initial accumulating value.
nextPartialResultA closure that combines the accumulating value and the latest value from
self. The result would be used in the next call ofnextPartialResult, or emit to the returnedSignalwhenselfcompletes.Return Value
A producer that sends the final value as
selfcompletes. -
Combine all values from
self, and forward the partial results and the final result.See
reduce(_:_:)if the resulting producer needs to forward only the final result.Declaration
Swift
public func scan<U>(_ initialResult: U, _ nextPartialResult: @escaping (U, Value) -> U) -> SignalProducer<U, Error>Parameters
initialResultThe value to use as the initial accumulating value.
nextPartialResultA closure that combines the accumulating value and the latest value from
self. The result would be forwarded, and would be used in the next call ofnextPartialResult.Return Value
A producer that sends the partial results of the accumuation, and the final result as
selfcompletes. -
Combine all values from
self, and forward the partial results and the final result.See
reduce(into:_:)if the resulting producer needs to forward only the final result.Declaration
Swift
public func scan<U>(into initialResult: U, _ nextPartialResult: @escaping (inout U, Value) -> Void) -> SignalProducer<U, Error>Parameters
initialResultThe value to use as the initial accumulating value.
nextPartialResultA closure that combines the accumulating value and the latest value from
self. The result would be forwarded, and would be used in the next call ofnextPartialResult.Return Value
A producer that sends the partial results of the accumuation, and the final result as
selfcompletes. -
Forward only values from
selfthat are not considered equivalent to its immediately preceding value.Note
The first value is always forwarded.
Declaration
Swift
public func skipRepeats(_ isEquivalent: @escaping (Value, Value) -> Bool) -> SignalProducer<Value, Error>Parameters
isEquivalentA closure to determine whether two values are equivalent.
Return Value
A producer which conditionally forwards values from
self -
Do not forward any value from
selfuntilshouldContinuereturnsfalse, at which point the returned signal starts to forward values fromself, including the one leading to the toggling.Declaration
Swift
public func skip(while shouldContinue: @escaping (Value) -> Bool) -> SignalProducer<Value, Error>Parameters
shouldContinueA closure to determine whether the skipping should continue.
Return Value
A producer which conditionally forwards values from
self. -
Forwards events from
selfuntilreplacementbegins sending events.Declaration
Swift
public func take(untilReplacement replacement: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>Parameters
replacementA producer to wait to wait for values from and start sending them as a replacement to
self‘s values.Return Value
A producer which passes through
value,failed, andinterruptedevents fromselfuntilreplacementsends an event, at which point the returned producer will send that event and switch to passing through events fromreplacementinstead, regardless of whetherselfhas sent events already. -
Forwards events from
selfuntilreplacementbegins sending events.Declaration
Swift
public func take<Replacement>(untilReplacement replacement: Replacement) -> SignalProducer<Value, Error> where Value == Replacement.Value, Error == Replacement.Error, Replacement : SignalProducerConvertibleParameters
replacementA producer to wait to wait for values from and start sending them as a replacement to
self‘s values.Return Value
A producer which passes through
value,failed, andinterruptedevents fromselfuntilreplacementsends an event, at which point the returned producer will send that event and switch to passing through events fromreplacementinstead, regardless of whetherselfhas sent events already. -
Wait until
selfcompletes and then forward the finalcountvalues on the returned producer.Declaration
Swift
public func take(last count: Int) -> SignalProducer<Value, Error>Parameters
countNumber of last events to send after
selfcompletes.Return Value
A producer that receives up to
countvalues fromselfafterselfcompletes. -
Forward any values from
selfuntilshouldContinuereturnsfalse, at which point the producedSignalwould complete.Declaration
Swift
public func take(while shouldContinue: @escaping (Value) -> Bool) -> SignalProducer<Value, Error>Parameters
shouldContinueA closure to determine whether the forwarding of values should continue.
Return Value
A producer which conditionally forwards values from
self. -
Zip elements of two producers into pairs. The elements of any Nth pair are the Nth elements of the two input producers.
Declaration
Swift
public func zip<U>(with other: SignalProducer<U, Error>) -> SignalProducer<(Value, U), Error>Parameters
otherA producer to zip values with.
Return Value
A producer that sends tuples of
selfandotherProducer. -
Zip elements of two producers into pairs. The elements of any Nth pair are the Nth elements of the two input producers.
Declaration
Swift
public func zip<Other>(with other: Other) -> SignalProducer<(Value, Other.Value), Error> where Error == Other.Error, Other : SignalProducerConvertibleParameters
otherA producer to zip values with.
Return Value
A producer that sends tuples of
selfandotherProducer. -
Apply an action to every value from
self, and forward the value if the action succeeds. If the action fails with an error, the producedSignalwould propagate the failure and terminate.Declaration
Swift
public func attempt(_ action: @escaping (Value) -> Result<(), Error>) -> SignalProducer<Value, Error>Parameters
actionAn action which yields a
Result.Return Value
A producer which forwards the values from
selfuntil the given action fails. -
Apply a transform to every value from
self, and forward the transformed value if the action succeeds. If the action fails with an error, the producedSignalwould propagate the failure and terminate.Declaration
Swift
public func attemptMap<U>(_ action: @escaping (Value) -> Result<U, Error>) -> SignalProducer<U, Error>Parameters
actionA transform which yields a
Resultof the transformed value or the error.Return Value
A producer which forwards the transformed values.
-
Forward the latest value on
schedulerafter at leastintervalseconds have passed since the returned signal last sent a value.If
selfalways sends values more frequently thanintervalseconds, then the returned signal will send a value everyintervalseconds.To measure from when
selflast sent a value, seedebounce.Seealso
debounceNote
If multiple values are received before the interval has elapsed, the latest value is the one that will be passed on.
Note
If
selfterminates while a value is being throttled, that value will be discarded and the returned producer will terminate immediately.Note
If the device time changed backwards before previous date while a value is being throttled, and if there is a new value sent, the new value will be passed anyway.
Declaration
Swift
public func throttle(_ interval: TimeInterval, on scheduler: DateScheduler) -> SignalProducer<Value, Error>Parameters
intervalNumber of seconds to wait between sent values.
schedulerA scheduler to deliver events on.
Return Value
A producer that sends values at least
intervalseconds appart on a given scheduler. -
Conditionally throttles values sent on the receiver whenever
shouldThrottleis true, forwarding values on the given scheduler.Note
While
shouldThrottleremains false, values are forwarded on the given scheduler. If multiple values are received whileshouldThrottleis true, the latest value is the one that will be passed on.Note
If the input signal terminates while a value is being throttled, that value will be discarded and the returned signal will terminate immediately.
Note
If
shouldThrottlecompletes before the receiver, and its last value istrue, the returned signal will remain in the throttled state, emitting no further values until it terminates.Declaration
Swift
public func throttle<P: PropertyProtocol>(while shouldThrottle: P, on scheduler: Scheduler) -> SignalProducer<Value, Error> where P.Value == BoolParameters
shouldThrottleA boolean property that controls whether values should be throttled.
schedulerA scheduler to deliver events on.
Return Value
A producer that sends values only while
shouldThrottleis false. -
Forward the latest value on
schedulerafter at leastintervalseconds have passed sinceselflast sent a value.If
selfalways sends values more frequently thanintervalseconds, then the returned signal will never send any values.To measure from when the returned signal last sent a value, see
throttle.Seealso
throttleNote
If multiple values are received before the interval has elapsed, the latest value is the one that will be passed on.
Note
If
selfterminates while a value is being debounced, the behaviour will be determined bydiscardWhenCompleted. Iftrue, that value will be discarded and the returned producer will terminate immediately. Iffalse, that value will be delivered at the next debounce interval.Declaration
Swift
public func debounce(_ interval: TimeInterval, on scheduler: DateScheduler, discardWhenCompleted: Bool = true) -> SignalProducer<Value, Error>Parameters
intervalA number of seconds to wait before sending a value.
schedulerA scheduler to send values on.
discardWhenCompletedA boolean to indicate if the latest value should be discarded on completion.
Return Value
A producer that sends values that are sent from
selfat leastintervalseconds apart. -
Forward events from
selfuntilinterval. Then if producer isn’t completed yet, fails witherroronscheduler.Note
If the interval is 0, the timeout will be scheduled immediately. The producer must complete synchronously (or on a faster scheduler) to avoid the timeout.
Declaration
Swift
public func timeout(after interval: TimeInterval, raising error: Error, on scheduler: DateScheduler) -> SignalProducer<Value, Error>Parameters
intervalNumber of seconds to wait for
selfto complete.errorError to send with
failedevent ifselfis not completed whenintervalpasses.schedulerA scheduler to deliver error on.
Return Value
A producer that sends events for at most
intervalseconds, then, if notcompleted- sendserrorwithfailedevent onscheduler. -
Forward only those values from
selfthat have unique identities across the set of all values that have been seen.Note
This causes the identities to be retained to check for uniqueness.
Declaration
Swift
public func uniqueValues<Identity: Hashable>(_ transform: @escaping (Value) -> Identity) -> SignalProducer<Value, Error>Parameters
transformA closure that accepts a value and returns identity value.
Return Value
A producer that sends unique values during its lifetime.
-
Injects side effects to be performed upon the specified producer events.
Note
In a composed producer,
startingis invoked in the reverse direction of the flow of events.Declaration
Swift
public func on( starting: (() -> Void)? = nil, started: (() -> Void)? = nil, event: ((ProducedSignal.Event) -> Void)? = nil, failed: ((Error) -> Void)? = nil, completed: (() -> Void)? = nil, interrupted: (() -> Void)? = nil, terminated: (() -> Void)? = nil, disposed: (() -> Void)? = nil, value: ((Value) -> Void)? = nil ) -> SignalProducer<Value, Error>Parameters
startingA closure that is invoked before the producer is started.
startedA closure that is invoked after the producer is started.
eventA closure that accepts an event and is invoked on every received event.
failedA closure that accepts error object and is invoked for
failedevent.completedA closure that is invoked for
completedevent.interruptedA closure that is invoked for
interruptedevent.terminatedA closure that is invoked for any terminating event.
disposedA closure added as disposable when signal completes.
valueA closure that accepts a value from
valueevent.Return Value
A producer with attached side-effects for given event cases.
-
Start the returned producer on the given
Scheduler.Note
This implies that any side effects embedded in the producer will be performed on the given scheduler as well.
Note
Events may still be sent upon other schedulers — this merely affects where the
start()method is run.Declaration
Swift
public func start(on scheduler: Scheduler) -> SignalProducer<Value, Error>Parameters
schedulerA scheduler to deliver events on.
Return Value
A producer that will deliver events on given
schedulerwhen started. -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B>(_ a: A, _ b: B) -> SignalProducer<(Value, B.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, A.Error == B.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C>(_ a: A, _ b: B, _ c: C) -> SignalProducer<(Value, B.Value, C.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C, D>(_ a: A, _ b: B, _ c: C, _ d: D) -> SignalProducer<(Value, B.Value, C.Value, D.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C, D, E>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C, D, E, F>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C, D, E, F, G>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C, D, E, F, G, H>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value, H.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error, G.Error == H.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C, D, E, F, G, H, I>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value, H.Value, I.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, I : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error, G.Error == H.Error, H.Error == I.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:).Declaration
Swift
public static func combineLatest<A, B, C, D, E, F, G, H, I, J>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I, _ j: J) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value, H.Value, I.Value, J.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, I : SignalProducerConvertible, J : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error, G.Error == H.Error, H.Error == I.Error, I.Error == J.Error -
Combines the values of all the given producers, in the manner described by
combineLatest(with:). Will return an emptySignalProducerif the sequence is empty.Declaration
Swift
public static func combineLatest<S>(_ producers: S) -> SignalProducer<[Value], Error> where Value == S.Element.Value, Error == S.Element.Error, S : Sequence, S.Element : SignalProducerConvertible -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B>(_ a: A, _ b: B) -> SignalProducer<(Value, B.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, A.Error == B.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C>(_ a: A, _ b: B, _ c: C) -> SignalProducer<(Value, B.Value, C.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C, D>(_ a: A, _ b: B, _ c: C, _ d: D) -> SignalProducer<(Value, B.Value, C.Value, D.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C, D, E>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C, D, E, F>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C, D, E, F, G>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C, D, E, F, G, H>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value, H.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error, G.Error == H.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C, D, E, F, G, H, I>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value, H.Value, I.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, I : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error, G.Error == H.Error, H.Error == I.Error -
Zips the values of all the given producers, in the manner described by
zip(with:).Declaration
Swift
public static func zip<A, B, C, D, E, F, G, H, I, J>(_ a: A, _ b: B, _ c: C, _ d: D, _ e: E, _ f: F, _ g: G, _ h: H, _ i: I, _ j: J) -> SignalProducer<(Value, B.Value, C.Value, D.Value, E.Value, F.Value, G.Value, H.Value, I.Value, J.Value), Error> where Value == A.Value, Error == A.Error, A : SignalProducerConvertible, B : SignalProducerConvertible, C : SignalProducerConvertible, D : SignalProducerConvertible, E : SignalProducerConvertible, F : SignalProducerConvertible, G : SignalProducerConvertible, H : SignalProducerConvertible, I : SignalProducerConvertible, J : SignalProducerConvertible, A.Error == B.Error, B.Error == C.Error, C.Error == D.Error, D.Error == E.Error, E.Error == F.Error, F.Error == G.Error, G.Error == H.Error, H.Error == I.Error, I.Error == J.Error -
Zips the values of all the given producers, in the manner described by
zipWith. Will return an emptySignalProducerif the sequence is empty.Declaration
Swift
public static func zip<S>(_ producers: S) -> SignalProducer<[Value], Error> where Value == S.Element.Value, Error == S.Element.Error, S : Sequence, S.Element : SignalProducerConvertible -
Repeat
selfa total ofcounttimes. In other words, start producercountnumber of times, each one after previously started producer completes.Note
Repeating
1time results in an equivalent signal producer.Note
Repeating
0times results in a producer that instantly completes.Precondition
countmust be non-negative integer.Declaration
Swift
public func `repeat`(_ count: Int) -> SignalProducer<Value, Error>Parameters
countNumber of repetitions.
Return Value
A signal producer start sequentially starts
selfafter previously started producer completes. -
Ignore failures up to
counttimes.Precondition
countmust be non-negative integer.Declaration
Swift
public func retry(upTo count: Int) -> SignalProducer<Value, Error>Parameters
countNumber of retries.
Return Value
A signal producer that restarts up to
counttimes. -
Delays retrying on failure by
intervalup tocountattempts.Precondition
countmust be non-negative integer.Declaration
Swift
public func retry(upTo count: Int, interval: TimeInterval, on scheduler: DateScheduler) -> SignalProducer<Value, Error>Parameters
countNumber of retries.
intervalAn interval between invocations.
schedulerA scheduler to deliver events on.
Return Value
A signal producer that restarts up to
counttimes. -
Wait for completion of
self, then forward all events fromreplacement. Any failure or interruption sent fromselfis forwarded immediately, in which casereplacementwill not be started, and none of its events will be be forwarded.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<U>(_ replacement: SignalProducer<U, Never>) -> SignalProducer<U, Error>Parameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement. Any failure or interruption sent fromselfis forwarded immediately, in which casereplacementwill not be started, and none of its events will be be forwarded.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Error> where Replacement : SignalProducerConvertible, Replacement.Error == NeverParameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement. Any failure or interruption sent fromselfis forwarded immediately, in which casereplacementwill not be started, and none of its events will be be forwarded.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<U>(_ replacement: SignalProducer<U, Error>) -> SignalProducer<U, Error>Parameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement. Any failure or interruption sent fromselfis forwarded immediately, in which casereplacementwill not be started, and none of its events will be be forwarded.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Error> where Error == Replacement.Error, Replacement : SignalProducerConvertibleParameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement. Any failure or interruption sent fromselfis forwarded immediately, in which casereplacementwill not be started, and none of its events will be be forwarded.Note
All values sent from
selfare ignored.Declaration
Swift
public func then(_ replacement: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>Parameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement. Any failure or interruption sent fromselfis forwarded immediately, in which casereplacementwill not be started, and none of its events will be be forwarded.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Value, Error> where Value == Replacement.Value, Error == Replacement.Error, Replacement : SignalProducerConvertibleParameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Start the producer, then block, waiting for the first value.
When a single value or error is sent, the returned
Resultwill represent those cases. However, when no values are sent,nilwill be returned.Declaration
Swift
public func first() -> Result<Value, Error>?Return Value
Result when single
valueorfailedevent is received.nilwhen no events are received. -
Start the producer, then block, waiting for events:
valueandcompleted.When a single value or error is sent, the returned
Resultwill represent those cases. However, when no values are sent, or when more than one value is sent,nilwill be returned.Declaration
Swift
public func single() -> Result<Value, Error>?Return Value
Result when single
valueorfailedevent is received.nilwhen 0 or more than 1 events are received. -
Start the producer, then block, waiting for the last value.
When a single value or error is sent, the returned
Resultwill represent those cases. However, when no values are sent,nilwill be returned.Declaration
Swift
public func last() -> Result<Value, Error>?Return Value
Result when single
valueorfailedevent is received.nilwhen no events are received. -
Starts the producer, then blocks, waiting for completion.
When a completion or error is sent, the returned
Resultwill represent those cases.Declaration
Swift
public func wait() -> Result<(), Error>Return Value
Result when single
completionorfailedevent is received. -
Creates a new
SignalProducerthat will multicast values emitted by the underlying producer, up tocapacity. This means that all clients of thisSignalProducerwill see the same version of the emitted values/errors.The underlying
SignalProducerwill not be started untilselfis started for the first time. When subscribing to this producer, all previous values (up tocapacity) will be emitted, followed by any new values.If you find yourself needing the current value (the last buffered value) you should consider using
PropertyTypeinstead, which, unlike this operator, will guarantee at compile time that there’s always a buffered value. This operator is not recommended in most cases, as it will introduce an implicit relationship between the original client and the rest, so consider alternatives likePropertyType, or representing your stream using aSignalinstead.This operator is only recommended when you absolutely need to introduce a layer of caching in front of another
SignalProducer.Precondition
capacitymust be non-negative integer.Declaration
Swift
public func replayLazily(upTo capacity: Int) -> SignalProducer<Value, Error>Parameters
capacityNumber of values to hold.
Return Value
A caching producer that will hold up to last
capacityvalues.
-
Flattens the inner producers sent upon
producer(into a single producer of values), according to the semantics of the given strategy.Note
If
produceror an active inner producer fails, the returned producer will forward that failure immediately.Warning
interruptedevents on inner producers will be treated likecompletedevents on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Error>Parameters
strategyStrategy used when flattening signals.
-
Flattens the inner producers sent upon
producer(into a single producer of values), according to the semantics of the given strategy.Note
If an active inner producer fails, the returned producer will forward that failure immediately.
Warning
interruptedevents on inner producers will be treated likecompletedevents on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Value.Error>Parameters
strategyStrategy used when flattening signals.
-
Flattens the inner producers sent upon
producer(into a single producer of values), according to the semantics of the given strategy.Warning
interruptedevents on inner producers will be treated likecompletedevents on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Value.Error>Parameters
strategyStrategy used when flattening signals.
-
Flattens the inner producers sent upon
signal(into a single signal of values), according to the semantics of the given strategy.Note
If
signalfails, the returned signal will forward that failure immediately.Warning
interruptedevents on inner producers will be treated likecompletedevents on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Error>Parameters
strategyStrategy used when flattening signals.
-
Flattens the
sequencevalue sent bysignal.Declaration
Swift
public func flatten() -> SignalProducer<Value.Iterator.Element, Error>
-
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Declaration
Swift
public func flatMap<U>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> SignalProducer<U, Error>) -> SignalProducer<U, Error>Parameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Declaration
Swift
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Error> where Inner.Error == ErrorParameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If any of the created producers fail, the returned producer will forward that failure immediately.
Declaration
Swift
public func flatMap<U, F>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> SignalProducer<U, F>) -> SignalProducer<U, F>Parameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Maps each event from
selfto a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If any of the created producers fail, the returned producer will forward that failure immediately.
Declaration
Swift
public func flatMap<Inner: SignalProducerConvertible>(_ strategy: FlattenStrategy, _ transform: @escaping (Value) -> Inner) -> SignalProducer<Inner.Value, Inner.Error>Parameters
strategyStrategy used when flattening signals.
transformA closure that takes a value emitted by
selfand returns a signal producer with transformed value. -
Creates a producer for a Signal that will immediately send the values from the given sequence, then complete.
Declaration
Swift
public init<S>(_ values: S) where Value == S.Element, S : SequenceParameters
valuesA sequence of values that a
Signalwill send as separatevalueevents and then complete. -
Creates a producer for a Signal that will immediately send the values from the given sequence, then complete.
Declaration
Swift
public init(values first: Value, _ second: Value, _ tail: Value...)
-
Create a
SignalProducerthat will attempt the given failable operation once for each invocation ofstart().Upon success, the started producer will send the resulting value then complete. Upon failure, the started signal will fail with the error that occurred.
Declaration
Swift
public init(_ action: @escaping () throws -> Value)Parameters
operationA failable closure.
-
Declaration
Swift
@discardableResult public func startWithValues(_ action: @escaping (Value) -> Void) -> DisposableParameters
actionA closure to be invoked with values from the produced
Signal.Return Value
A disposable to interrupt the produced
Signal.
-
Unwraps non-
nilvalues and forwards them on the returned signal,nilvalues are dropped.Declaration
Swift
public func skipNil() -> SignalProducer<Value.Wrapped, Error>Return Value
A producer that sends only non-nil values.
-
The inverse of materialize(), this will translate a producer of
Eventvalues into a producer of those events themselves.Declaration
Swift
public func dematerialize() -> SignalProducer<Value.Value, Value.Error>Return Value
A producer that sends values carried by
selfevents.
-
The inverse of materializeResults(), this will translate a producer of
Resultvalues into a producer of those events themselves.Declaration
Swift
public func dematerializeResults<Success, Failure>() -> SignalProducer<Success, Failure> where Value == Result<Success, Failure>, Failure : ErrorReturn Value
A producer that sends values carried by
selfresults. -
Promote a producer that does not generate failures into one that can.
Note
This does not actually cause failers to be generated for the given producer, but makes it easier to combine with other producers that may fail; for example, with operators like
combineLatestWith,zipWith,flatten, etc.Declaration
Swift
public func promoteError<F>(_: F.Type = F.self) -> SignalProducer<Value, F> where F : ErrorReturn Value
A producer that has an instantiatable
ErrorType. -
Promote a producer that does not generate failures into one that can.
Note
This does not actually cause failers to be generated for the given producer, but makes it easier to combine with other producers that may fail; for example, with operators like
combineLatestWith,zipWith,flatten, etc.Declaration
Swift
public func promoteError(_: Error.Type = Error.self) -> SignalProducer<Value, Error>Return Value
A producer that has an instantiatable
ErrorType. -
Forward events from
selfuntilinterval. Then if producer isn’t completed yet, fails witherroronscheduler.Note
If the interval is 0, the timeout will be scheduled immediately. The producer must complete synchronously (or on a faster scheduler) to avoid the timeout.
Declaration
Swift
public func timeout<NewError>( after interval: TimeInterval, raising error: NewError, on scheduler: DateScheduler ) -> SignalProducer<Value, NewError>Parameters
intervalNumber of seconds to wait for
selfto complete.errorError to send with
failedevent ifselfis not completed whenintervalpasses.scheudlerA scheduler to deliver error on.
Return Value
A producer that sends events for at most
intervalseconds, then, if notcompleted- sendserrorwithfailedevent onscheduler. -
Apply a throwable action to every value from
self, and forward the values if the action succeeds. If the action throws an error, the producedSignalwould propagate the failure and terminate.Declaration
Swift
public func attempt(_ action: @escaping (Value) throws -> Void) -> SignalProducer<Value, Swift.Error>Parameters
actionA throwable closure to perform an arbitrary action on the value.
Return Value
A producer which forwards the successful values of the given action.
-
Apply a throwable action to every value from
self, and forward the results if the action succeeds. If the action throws an error, the producedSignalwould propagate the failure and terminate.Declaration
Swift
public func attemptMap<U>(_ action: @escaping (Value) throws -> U) -> SignalProducer<U, Swift.Error>Parameters
actionA throwable closure to perform an arbitrary action on the value, and yield a result.
Return Value
A producer which forwards the successful results of the given action.
-
Apply a throwable action to every value from
self, and forward the values if the action succeeds. If the action throws an error, the producedSignalwould propagate the failure and terminate.Declaration
Swift
public func attempt(_ action: @escaping (Value) throws -> Void) -> SignalProducer<Value, Error>Parameters
actionA throwable closure to perform an arbitrary action on the value.
Return Value
A producer which forwards the successful values of the given action.
-
Apply a throwable transform to every value from
self, and forward the results if the action succeeds. If the transform throws an error, the producedSignalwould propagate the failure and terminate.Declaration
Swift
public func attemptMap<U>(_ transform: @escaping (Value) throws -> U) -> SignalProducer<U, Error>Parameters
transformA throwable transform.
Return Value
A producer which forwards the successfully transformed values.
-
Promote a producer that does not generate values, as indicated by
Never, to be a producer of the given type of value.Note
The promotion does not result in any value being generated.
Declaration
Swift
public func promoteValue<U>(_: U.Type = U.self) -> SignalProducer<U, Error>Return Value
A producer that forwards all terminal events from
self. -
Promote a producer that does not generate values, as indicated by
Never, to be a producer of the given type of value.Note
The promotion does not result in any value being generated.
Declaration
Swift
public func promoteValue(_: Value.Type = Value.self) -> SignalProducer<Value, Error>Return Value
A producer that forwards all terminal events from
self.
-
Forward only values from
selfthat are not equal to its immediately preceding value.Note
The first value is always forwarded.
Declaration
Swift
public func skipRepeats() -> SignalProducer<Value, Error>Return Value
A producer which conditionally forwards values from
self.
-
Forward only those values from
selfthat are unique across the set of all values that have been seen.Note
This causes the values to be retained to check for uniqueness. Providing a function that returns a unique value for each sent value can help you reduce the memory footprint.
Declaration
Swift
public func uniqueValues() -> SignalProducer<Value, Error>Return Value
A producer that sends unique values during its lifetime.
-
Wait for completion of
self, then forward all events fromreplacement.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<U, F>(_ replacement: SignalProducer<U, F>) -> SignalProducer<U, F> where F : ErrorParameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Replacement.Error> where Replacement : SignalProducerConvertibleParameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<U>(_ replacement: SignalProducer<U, Never>) -> SignalProducer<U, Never>Parameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Never> where Replacement : SignalProducerConvertible, Replacement.Error == NeverParameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement.Note
All values sent from
selfare ignored.Declaration
Swift
public func then(_ replacement: SignalProducer<Value, Never>) -> SignalProducer<Value, Never>Parameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes. -
Wait for completion of
self, then forward all events fromreplacement.Note
All values sent from
selfare ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Value, Never> where Value == Replacement.Value, Replacement : SignalProducerConvertible, Replacement.Error == NeverParameters
replacementA producer to start when
selfcompletes.Return Value
A producer that sends events from
selfand then fromreplacementwhenselfcompletes.
-
Create a producer that computes a logical NOT in the latest values of
self.Declaration
Swift
public func negate() -> SignalProducer<Value, Error>Return Value
A producer that emits the logical NOT results.
-
Create a producer that computes a logical AND between the latest values of
selfandproducer.Declaration
Swift
public func and(_ booleans: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>Parameters
booleansA producer of booleans to be combined with
self.Return Value
A producer that emits the logical AND results.
-
Create a producer that computes a logical AND between the latest values of
selfandproducer.Declaration
Swift
public func and<Booleans>(_ booleans: Booleans) -> SignalProducer<Value, Error> where Error == Booleans.Error, Booleans : SignalProducerConvertible, Booleans.Value == BoolParameters
booleansA producer of booleans to be combined with
self.Return Value
A producer that emits the logical AND results.
-
Create a producer that computes a logical AND between the latest values of
booleans.Declaration
Swift
public static func all<BooleansCollection>(_ booleans: BooleansCollection) -> SignalProducer<Value, Error> where BooleansCollection : Collection, BooleansCollection.Element == SignalProducer<Bool, Error>Parameters
booleansA collection of boolean producers to be combined.
Return Value
A producer that emits the logical AND results.
-
Create a producer that computes a logical AND between the latest values of
booleans.Declaration
Swift
public static func all<Booleans, BooleansCollection>(_ booleans: BooleansCollection) -> SignalProducer<Value, Error> where Error == Booleans.Error, Booleans : SignalProducerConvertible, Booleans == BooleansCollection.Element, BooleansCollection : Collection, Booleans.Value == BoolParameters
booleansA collection of boolean producers to be combined.
Return Value
A producer that emits the logical AND results.
-
Create a producer that computes a logical OR between the latest values of
selfandproducer.Declaration
Swift
public func or(_ booleans: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>Parameters
booleansA producer of booleans to be combined with
self.Return Value
A producer that emits the logical OR results.
-
Create a producer that computes a logical OR between the latest values of
selfandproducer.Declaration
Swift
public func or<Booleans>(_ booleans: Booleans) -> SignalProducer<Value, Error> where Error == Booleans.Error, Booleans : SignalProducerConvertible, Booleans.Value == BoolParameters
booleansA producer of booleans to be combined with
self.Return Value
A producer that emits the logical OR results.
-
Create a producer that computes a logical OR between the latest values of
booleans.Declaration
Swift
public static func any<BooleansCollection>(_ booleans: BooleansCollection) -> SignalProducer<Value, Error> where BooleansCollection : Collection, BooleansCollection.Element == SignalProducer<Bool, Error>Parameters
booleansA collection of boolean producers to be combined.
Return Value
A producer that emits the logical OR results.
-
Create a producer that computes a logical OR between the latest values of
booleans.Declaration
Swift
public static func any<Booleans, BooleansCollection>(_ booleans: BooleansCollection) -> SignalProducer<Value, Error> where Error == Booleans.Error, Booleans : SignalProducerConvertible, Booleans == BooleansCollection.Element, BooleansCollection : Collection, Booleans.Value == BoolParameters
booleansA collection of boolean producers to be combined.
Return Value
A producer that emits the logical OR results.
-
Create a repeating timer of the given interval, with a reasonable default leeway, sending updates on the given scheduler.
Note
This timer will never complete naturally, so all invocations of
start()must be disposed to avoid leaks.Precondition
intervalmust be non-negative number.Note
If you plan to specify an
intervalvalue greater than 200,000 seconds, usetimer(interval:on:leeway:)instead and specify your ownleewayvalue to avoid potential overflow.Declaration
Swift
public static func timer(interval: DispatchTimeInterval, on scheduler: DateScheduler) -> SignalProducer<Value, Error>Parameters
intervalAn interval between invocations.
schedulerA scheduler to deliver events on.
Return Value
A producer that sends
Datevalues everyintervalseconds. -
Creates a repeating timer of the given interval, sending updates on the given scheduler.
Note
This timer will never complete naturally, so all invocations of
start()must be disposed to avoid leaks.Precondition
intervalmust be non-negative number.Precondition
leewaymust be non-negative number.Declaration
Swift
public static func timer(interval: DispatchTimeInterval, on scheduler: DateScheduler, leeway: DispatchTimeInterval) -> SignalProducer<Value, Error>Parameters
intervalAn interval between invocations.
schedulerA scheduler to deliver events on.
leewayInterval leeway. Apple’s “Power Efficiency Guide for Mac Apps” recommends a leeway of at least 10% of the timer interval.
Return Value
A producer that sends
Datevalues everyintervalseconds.
View on GitHub
Install in Dash
SignalProducer Structure Reference