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 : SignalProducerConvertible
Parameters
base
The entity to convert from.
-
Initializes a
SignalProducer
that 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
signal
A signal to observe after starting the producer.
-
Initialize a
SignalProducer
which 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
Observer
to emit events to the producedSignal
; and (2) aLifetime
to bind resources to the lifetime of the producedSignal
.The
Lifetime
of a producedSignal
ends when: (1) a terminal event is sent to the inputObserver
; or (2) when the producedSignal
is interrupted via the disposable yielded at the starting call.Declaration
Parameters
startHandler
The starting side effect.
-
Creates a producer for a
Signal
that immediately sends one value, then completes.This initializer differs from
init(value:)
in that its solevalue
event is constructed lazily by invoking the suppliedaction
when theSignalProducer
is started.Declaration
Swift
public init(_ action: @escaping () -> Value)
Parameters
action
A action that yields a value to be sent by the
Signal
as avalue
event. -
Create a
SignalProducer
that 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
action
A 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
result
A
Result
instance that will send eithervalue
event ifresult
issuccess
ful orfailed
event ifresult
is 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 : Sequence
Parameters
values
A sequence of values that a
Signal
will send as separatevalue
events 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
Signal
fromself
, pass it into the given closure, and start the associated work on the producedSignal
as the closure returns.Declaration
Swift
@discardableResult public func startWithSignal<Result>(_ setup: (_ signal: Signal<Value, Error>, _ interruptHandle: Disposable) -> Result) -> Result
Parameters
setup
Return 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
identifier
a string to identify the SignalProducer firing events.
events
Types of events to log.
fileName
Name of the file containing the code which fired the event.
functionName
Function where event was fired.
lineNumber
Line number where event was fired.
logger
Logger that logs the events.
Return Value
Signal producer that, when started, logs the fired events.
-
concat
snext
ontoself
.Declaration
Swift
public func concat(_ next: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>
Parameters
next
A follow-up producer to concat
self
with.Return Value
A producer that will start
self
and then on completion ofself
- will startnext
. -
concat
snext
ontoself
.Declaration
Swift
public func concat<Next>(_ next: Next) -> SignalProducer<Value, Error> where Value == Next.Value, Error == Next.Error, Next : SignalProducerConvertible
Parameters
next
A follow-up producer to concat
self
with.Return Value
A producer that will start
self
and then on completion ofself
- will startnext
. -
concat
svalue
ontoself
.Declaration
Swift
public func concat(value: Value) -> SignalProducer<Value, Error>
Parameters
value
A value to concat onto
self
.Return Value
A producer that, when started, will emit own values and on completion will emit a
value
. -
concat
serror
ontoself
.Declaration
Swift
public func concat(error: Error) -> SignalProducer<Value, Error>
Parameters
error
An error to concat onto
self
.Return Value
A producer that, when started, will emit own values and on completion will emit an
error
. -
concat
sself
onto initialprevious
.Declaration
Swift
public func prefix(_ previous: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>
Parameters
previous
A producer to start before
self
.Return Value
A signal producer that, when started, first emits values from
previous
producer and then fromself
. -
concat
sself
onto initialprevious
.Declaration
Swift
public func prefix<Previous>(_ previous: Previous) -> SignalProducer<Value, Error> where Value == Previous.Value, Error == Previous.Error, Previous : SignalProducerConvertible
Parameters
previous
A producer to start before
self
.Return Value
A signal producer that, when started, first emits values from
previous
producer and then fromself
. -
concat
sself
onto initialvalue
.Declaration
Swift
public func prefix(value: Value) -> SignalProducer<Value, Error>
Parameters
value
A 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
SignalProducer
that 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
producers
A 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
self
to a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
self
or 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
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and returns a signal producer with transformed value. -
Maps each event from
self
to a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
self
or 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 == Error
Parameters
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and returns a signal producer with transformed value. -
Maps each event from
self
to a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
self
fails, 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
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and returns a signal producer with transformed value. -
Maps each event from
self
to a new producer, then flattens the resulting producers (into a producer of values), according to the semantics of the given strategy.Warning
If
self
fails, 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 == Never
Parameters
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and 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
transform
A 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 == Value
Parameters
transform
A 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
Signal
fromself
, and observe it with the given observer.Declaration
Swift
@discardableResult public func start(_ observer: Signal<Value, Error>.Observer = .init()) -> Disposable
Parameters
observer
An 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) -> Disposable
Parameters
action
A closure to be invoked with every event from
self
.Return Value
A disposable to interrupt the produced
Signal
. -
Create a
Signal
fromself
, and observe theSignal
for all values being emitted, and if any, its failure.Declaration
Swift
@discardableResult public func startWithResult(_ action: @escaping (Result<Value, Error>) -> Void) -> Disposable
Parameters
action
A closure to be invoked with values from
self
, or the propagated error should anyfailed
event is emitted.Return Value
A disposable to interrupt the produced
Signal
. -
Create a
Signal
fromself
, and observe its completion.Declaration
Swift
@discardableResult public func startWithCompleted(_ action: @escaping () -> Void) -> Disposable
Parameters
action
A closure to be invoked when a
completed
event is emitted.Return Value
A disposable to interrupt the produced
Signal
. -
Create a
Signal
fromself
, and observe its failure.Declaration
Swift
@discardableResult public func startWithFailed(_ action: @escaping (Error) -> Void) -> Disposable
Parameters
action
A closure to be invoked with the propagated error, should any
failed
event is emitted.Return Value
A disposable to interrupt the produced
Signal
. -
Create a
Signal
fromself
, and observe its interruption.Declaration
Swift
@discardableResult public func startWithInterrupted(_ action: @escaping () -> Void) -> Disposable
Parameters
action
A closure to be invoked when an
interrupted
event 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
SignalProducer
which will apply the givenSignal
operator to every createdSignal
, just as if the operator had been applied to eachSignal
yielded fromstart()
.Declaration
Parameters
transform
An 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
SignalProducer
which will apply the givenSignal
operator to everySignal
created from the two producers, just as if the operator had been applied to eachSignal
yielded fromstart()
.Note
starting the returned producer will start the receiver of the operator, which may not be adviseable for some operators.
Declaration
Parameters
transform
A 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
transform
A 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
value
A 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
keyPath
A key path relative to the producer’s
Value
type.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
transform
A 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. Ifscheduler
has not yet scheduledtransform
for execution, then each new value will replace the last one as the parameter totransform
once it is finally executed.Declaration
Swift
public func lazyMap<U>(on scheduler: Scheduler, transform: @escaping (Value) -> U) -> SignalProducer<U, Error>
Parameters
transform
The closure used to obtain the returned value from this producer’s underlying value.
Return Value
A producer that, when started, sends values obtained using
transform
as 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
isIncluded
A closure to determine whether a value from
self
should be included in the producedSignal
.Return Value
A producer that, when started, forwards the values passing the given closure.
-
Applies
transform
to values from the producer and forwards values with nonnil
results unwrapped.Declaration
Swift
public func compactMap<U>(_ transform: @escaping (Value) -> U?) -> SignalProducer<U, Error>
Parameters
transform
A closure that accepts a value from the
value
event and returns a new optional value.Return Value
A producer that will send new values, that are non
nil
after the transformation. -
Applies
transform
to values from the producer and forwards values with nonnil
results unwrapped.Declaration
Swift
@available(*, deprecated, renamed: "compactMap") public func filterMap<U>(_ transform: @escaping (Value) -> U?) -> SignalProducer<U, Error>
Parameters
transform
A closure that accepts a value from the
value
event and returns a new optional value.Return Value
A producer that will send new values, that are non
nil
after the transformation. -
Yield the first
count
values from the input producer.Precondition
count
must be non-negative number.Declaration
Swift
public func take(first count: Int) -> SignalProducer<Value, Error>
Parameters
count
A number of values to take from the signal.
Return Value
A producer that, when started, will yield the first
count
values fromself
. -
Yield an array of values when
self
completes.Note
When
self
completes 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
self
completes. -
Yield an array of values until it reaches a certain count.
Precondition
count
must 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
self
completes any remaining values will be sent, the last array may not havecount
values. 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
count
values fromself
, forwards them as a single array and completes. -
Collect values from
self
, and emit them if the predicate passes.When
self
completes any remaining values will be sent, regardless of the collected values matchingshouldEmit
or not.If
self
completes 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
shouldEmit
A 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
shouldEmit
closure. -
Collect values from
self
, and emit them if the predicate passes.When
self
completes any remaining values will be sent, regardless of the collected values matchingshouldEmit
or not.If
self
completes 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
shouldEmit
A 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
shouldEmit
closure. -
Forward the latest values on
scheduler
everyinterval
.Note
If
self
terminates 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
interval
A repetition interval.
scheduler
A scheduler to send values on.
skipEmpty
Whether empty arrays should be sent if no values were accumulated during the interval.
discardWhenCompleted
A 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
self
atinterval
seconds 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
scheduler
A scheduler to deliver events on.
Return Value
A producer that, when started, will yield
self
values 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
other
A producer to combine
self
‘s value with.Return Value
A producer that, when started, will yield a tuple containing values of
self
and 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 : SignalProducerConvertible
Parameters
other
A producer to combine
self
‘s value with.Return Value
A producer that, when started, will yield a tuple containing values of
self
and given producer. -
Merge the given producer into a single
SignalProducer
that 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
other
A producer to merge
self
‘s value with.Return Value
A producer that sends all values of
self
and given producer. -
Merge the given producer into a single
SignalProducer
that 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 : SignalProducerConvertible
Parameters
other
A producer to merge
self
‘s value with.Return Value
A producer that sends all values of
self
and given producer. -
Delay
value
andcompleted
events by the given interval, forwarding them on the given scheduler.Note
failed
andinterrupted
events are always scheduled immediately.Declaration
Swift
public func delay(_ interval: TimeInterval, on scheduler: DateScheduler) -> SignalProducer<Value, Error>
Parameters
interval
Interval to delay
value
andcompleted
events by.scheduler
A scheduler to deliver delayed events on.
Return Value
A producer that, when started, will delay
value
andcompleted
events and will yield them on given scheduler. -
Skip the first
count
values, then forward everything afterward.Declaration
Swift
public func skip(first count: Int) -> SignalProducer<Value, Error>
Parameters
count
A number of values to skip.
Return Value
A producer that, when started, will skip the first
count
values, 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
interrupted
event is received, the resulting producer will send theEvent
itself 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.failure
itself 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
self
with the value fromsampler
as a tuple, only whensampler
sends avalue
event.Note
If
sampler
fires 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
sampler
A producer that will trigger the delivery of
value
event fromself
.Return Value
A producer that will send values from
self
andsampler
, 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
self
with the value fromsampler
as a tuple, only whensampler
sends avalue
event.Note
If
sampler
fires 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 == Never
Parameters
sampler
A producer that will trigger the delivery of
value
event fromself
.Return Value
A producer that will send values from
self
andsampler
, 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
self
wheneversampler
sends avalue
event.Note
If
sampler
fires before a value has been observed onself
, nothing happens.Declaration
Swift
public func sample(on sampler: SignalProducer<(), Never>) -> SignalProducer<Value, Error>
Parameters
sampler
A producer that will trigger the delivery of
value
event 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
self
wheneversampler
sends avalue
event.Note
If
sampler
fires 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
sampler
A producer that will trigger the delivery of
value
event 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
samplee
with the value fromself
as a tuple, only whenself
sends avalue
event. This is like a flipped version ofsample(with:)
, butsamplee
‘s terminal events are completely ignored.Note
If
self
fires 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
samplee
A producer whose latest value is sampled by
self
.Return Value
A producer that will send values from
self
andsamplee
, sampled (possibly multiple times) byself
, then terminate onceself
has terminated.samplee
‘s terminated events are ignored. -
Forward the latest value from
samplee
with the value fromself
as a tuple, only whenself
sends avalue
event. This is like a flipped version ofsample(with:)
, butsamplee
‘s terminal events are completely ignored.Note
If
self
fires 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 == Never
Parameters
samplee
A producer whose latest value is sampled by
self
.Return Value
A producer that will send values from
self
andsamplee
, sampled (possibly multiple times) byself
, then terminate onceself
has terminated.samplee
‘s terminated events are ignored. -
Forwards events from
self
untillifetime
ends, at which point the returned producer will complete.Declaration
Swift
public func take(during lifetime: Lifetime) -> SignalProducer<Value, Error>
Parameters
lifetime
A lifetime whose
ended
signal will cause the returned producer to complete.Return Value
A producer that will deliver events until
lifetime
ends. -
Forward events from
self
untiltrigger
sends avalue
orcompleted
event, at which point the returned producer will complete.Declaration
Swift
public func take(until trigger: SignalProducer<(), Never>) -> SignalProducer<Value, Error>
Parameters
trigger
A producer whose
value
orcompleted
events will stop the delivery ofvalue
events fromself
.Return Value
A producer that will deliver events until
trigger
sendsvalue
orcompleted
events. -
Forward events from
self
untiltrigger
sends avalue
orcompleted
event, 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
trigger
A producer whose
value
orcompleted
events will stop the delivery ofvalue
events fromself
.Return Value
A producer that will deliver events until
trigger
sendsvalue
orcompleted
events. -
Do not forward any values from
self
untiltrigger
sends avalue
orcompleted
, at which point the returned producer behaves exactly likeproducer
.Declaration
Swift
public func skip(until trigger: SignalProducer<(), Never>) -> SignalProducer<Value, Error>
Parameters
trigger
A producer whose
value
orcompleted
events will start the deliver of events onself
.Return Value
A producer that will deliver events once the
trigger
sendsvalue
orcompleted
events. -
Do not forward any values from
self
untiltrigger
sends avalue
orcompleted
, 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
trigger
A producer whose
value
orcompleted
events will start the deliver of events onself
.Return Value
A producer that will deliver events once the
trigger
sendsvalue
orcompleted
events. -
Forward events from
self
with history: values of the returned producer are a tuples whose first member is the previous value and whose second member is the current value.initial
is supplied as the first member whenself
sends its first value.Declaration
Swift
public func combinePrevious(_ initial: Value) -> SignalProducer<(Value, Value), Error>
Parameters
initial
A 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
self
with 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
Signal
would 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
initialResult
The value to use as the initial accumulating value.
nextPartialResult
A 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 returnedSignal
whenself
completes.Return Value
A producer that sends the final result as
self
completes. -
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
initialResult
The value to use as the initial accumulating value.
nextPartialResult
A 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 returnedSignal
whenself
completes.Return Value
A producer that sends the final value as
self
completes. -
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
initialResult
The value to use as the initial accumulating value.
nextPartialResult
A 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
self
completes. -
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
initialResult
The value to use as the initial accumulating value.
nextPartialResult
A 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
self
completes. -
Forward only values from
self
that 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
isEquivalent
A closure to determine whether two values are equivalent.
Return Value
A producer which conditionally forwards values from
self
-
Do not forward any value from
self
untilshouldContinue
returnsfalse
, 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
shouldContinue
A closure to determine whether the skipping should continue.
Return Value
A producer which conditionally forwards values from
self
. -
Forwards events from
self
untilreplacement
begins sending events.Declaration
Swift
public func take(untilReplacement replacement: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>
Parameters
replacement
A 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
, andinterrupted
events fromself
untilreplacement
sends an event, at which point the returned producer will send that event and switch to passing through events fromreplacement
instead, regardless of whetherself
has sent events already. -
Forwards events from
self
untilreplacement
begins sending events.Declaration
Swift
public func take<Replacement>(untilReplacement replacement: Replacement) -> SignalProducer<Value, Error> where Value == Replacement.Value, Error == Replacement.Error, Replacement : SignalProducerConvertible
Parameters
replacement
A 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
, andinterrupted
events fromself
untilreplacement
sends an event, at which point the returned producer will send that event and switch to passing through events fromreplacement
instead, regardless of whetherself
has sent events already. -
Wait until
self
completes and then forward the finalcount
values on the returned producer.Declaration
Swift
public func take(last count: Int) -> SignalProducer<Value, Error>
Parameters
count
Number of last events to send after
self
completes.Return Value
A producer that receives up to
count
values fromself
afterself
completes. -
Forward any values from
self
untilshouldContinue
returnsfalse
, at which point the producedSignal
would complete.Declaration
Swift
public func take(while shouldContinue: @escaping (Value) -> Bool) -> SignalProducer<Value, Error>
Parameters
shouldContinue
A 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
other
A producer to zip values with.
Return Value
A producer that sends tuples of
self
andotherProducer
. -
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 : SignalProducerConvertible
Parameters
other
A producer to zip values with.
Return Value
A producer that sends tuples of
self
andotherProducer
. -
Apply an action to every value from
self
, and forward the value if the action succeeds. If the action fails with an error, the producedSignal
would propagate the failure and terminate.Declaration
Swift
public func attempt(_ action: @escaping (Value) -> Result<(), Error>) -> SignalProducer<Value, Error>
Parameters
action
An action which yields a
Result
.Return Value
A producer which forwards the values from
self
until 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 producedSignal
would propagate the failure and terminate.Declaration
Swift
public func attemptMap<U>(_ action: @escaping (Value) -> Result<U, Error>) -> SignalProducer<U, Error>
Parameters
action
A transform which yields a
Result
of the transformed value or the error.Return Value
A producer which forwards the transformed values.
-
Forward the latest value on
scheduler
after at leastinterval
seconds have passed since the returned signal last sent a value.If
self
always sends values more frequently thaninterval
seconds, then the returned signal will send a value everyinterval
seconds.To measure from when
self
last sent a value, seedebounce
.Seealso
debounce
Note
If multiple values are received before the interval has elapsed, the latest value is the one that will be passed on.
Note
If
self
terminates 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
interval
Number of seconds to wait between sent values.
scheduler
A scheduler to deliver events on.
Return Value
A producer that sends values at least
interval
seconds appart on a given scheduler. -
Conditionally throttles values sent on the receiver whenever
shouldThrottle
is true, forwarding values on the given scheduler.Note
While
shouldThrottle
remains false, values are forwarded on the given scheduler. If multiple values are received whileshouldThrottle
is 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
shouldThrottle
completes 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 == Bool
Parameters
shouldThrottle
A boolean property that controls whether values should be throttled.
scheduler
A scheduler to deliver events on.
Return Value
A producer that sends values only while
shouldThrottle
is false. -
Forward the latest value on
scheduler
after at leastinterval
seconds have passed sinceself
last sent a value.If
self
always sends values more frequently thaninterval
seconds, then the returned signal will never send any values.To measure from when the returned signal last sent a value, see
throttle
.Seealso
throttle
Note
If multiple values are received before the interval has elapsed, the latest value is the one that will be passed on.
Note
If
self
terminates 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
interval
A number of seconds to wait before sending a value.
scheduler
A scheduler to send values on.
discardWhenCompleted
A boolean to indicate if the latest value should be discarded on completion.
Return Value
A producer that sends values that are sent from
self
at leastinterval
seconds apart. -
Forward events from
self
untilinterval
. Then if producer isn’t completed yet, fails witherror
onscheduler
.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
interval
Number of seconds to wait for
self
to complete.error
Error to send with
failed
event ifself
is not completed wheninterval
passes.scheduler
A scheduler to deliver error on.
Return Value
A producer that sends events for at most
interval
seconds, then, if notcompleted
- sendserror
withfailed
event onscheduler
. -
Forward only those values from
self
that 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
transform
A 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,
starting
is 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
starting
A closure that is invoked before the producer is started.
started
A closure that is invoked after the producer is started.
event
A closure that accepts an event and is invoked on every received event.
failed
A closure that accepts error object and is invoked for
failed
event.completed
A closure that is invoked for
completed
event.interrupted
A closure that is invoked for
interrupted
event.terminated
A closure that is invoked for any terminating event.
disposed
A closure added as disposable when signal completes.
value
A closure that accepts a value from
value
event.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
scheduler
A scheduler to deliver events on.
Return Value
A producer that will deliver events on given
scheduler
when 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 emptySignalProducer
if 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 emptySignalProducer
if 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
self
a total ofcount
times. In other words, start producercount
number of times, each one after previously started producer completes.Note
Repeating
1
time results in an equivalent signal producer.Note
Repeating
0
times results in a producer that instantly completes.Precondition
count
must be non-negative integer.Declaration
Swift
public func `repeat`(_ count: Int) -> SignalProducer<Value, Error>
Parameters
count
Number of repetitions.
Return Value
A signal producer start sequentially starts
self
after previously started producer completes. -
Ignore failures up to
count
times.Precondition
count
must be non-negative integer.Declaration
Swift
public func retry(upTo count: Int) -> SignalProducer<Value, Error>
Parameters
count
Number of retries.
Return Value
A signal producer that restarts up to
count
times. -
Delays retrying on failure by
interval
up tocount
attempts.Precondition
count
must be non-negative integer.Declaration
Swift
public func retry(upTo count: Int, interval: TimeInterval, on scheduler: DateScheduler) -> SignalProducer<Value, Error>
Parameters
count
Number of retries.
interval
An interval between invocations.
scheduler
A scheduler to deliver events on.
Return Value
A signal producer that restarts up to
count
times. -
Wait for completion of
self
, then forward all events fromreplacement
. Any failure or interruption sent fromself
is forwarded immediately, in which casereplacement
will not be started, and none of its events will be be forwarded.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<U>(_ replacement: SignalProducer<U, Never>) -> SignalProducer<U, Error>
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
. Any failure or interruption sent fromself
is forwarded immediately, in which casereplacement
will not be started, and none of its events will be be forwarded.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Error> where Replacement : SignalProducerConvertible, Replacement.Error == Never
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
. Any failure or interruption sent fromself
is forwarded immediately, in which casereplacement
will not be started, and none of its events will be be forwarded.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<U>(_ replacement: SignalProducer<U, Error>) -> SignalProducer<U, Error>
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
. Any failure or interruption sent fromself
is forwarded immediately, in which casereplacement
will not be started, and none of its events will be be forwarded.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Error> where Error == Replacement.Error, Replacement : SignalProducerConvertible
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
. Any failure or interruption sent fromself
is forwarded immediately, in which casereplacement
will not be started, and none of its events will be be forwarded.Note
All values sent from
self
are ignored.Declaration
Swift
public func then(_ replacement: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
. Any failure or interruption sent fromself
is forwarded immediately, in which casereplacement
will not be started, and none of its events will be be forwarded.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Value, Error> where Value == Replacement.Value, Error == Replacement.Error, Replacement : SignalProducerConvertible
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Start the producer, then block, waiting for the first value.
When a single value or error is sent, the returned
Result
will represent those cases. However, when no values are sent,nil
will be returned.Declaration
Swift
public func first() -> Result<Value, Error>?
Return Value
Result when single
value
orfailed
event is received.nil
when no events are received. -
Start the producer, then block, waiting for events:
value
andcompleted
.When a single value or error is sent, the returned
Result
will represent those cases. However, when no values are sent, or when more than one value is sent,nil
will be returned.Declaration
Swift
public func single() -> Result<Value, Error>?
Return Value
Result when single
value
orfailed
event is received.nil
when 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
Result
will represent those cases. However, when no values are sent,nil
will be returned.Declaration
Swift
public func last() -> Result<Value, Error>?
Return Value
Result when single
value
orfailed
event is received.nil
when no events are received. -
Starts the producer, then blocks, waiting for completion.
When a completion or error is sent, the returned
Result
will represent those cases.Declaration
Swift
public func wait() -> Result<(), Error>
Return Value
Result when single
completion
orfailed
event is received. -
Creates a new
SignalProducer
that will multicast values emitted by the underlying producer, up tocapacity
. This means that all clients of thisSignalProducer
will see the same version of the emitted values/errors.The underlying
SignalProducer
will not be started untilself
is 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
PropertyType
instead, 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 aSignal
instead.This operator is only recommended when you absolutely need to introduce a layer of caching in front of another
SignalProducer
.Precondition
capacity
must be non-negative integer.Declaration
Swift
public func replayLazily(upTo capacity: Int) -> SignalProducer<Value, Error>
Parameters
capacity
Number of values to hold.
Return Value
A caching producer that will hold up to last
capacity
values.
-
Flattens the inner producers sent upon
producer
(into a single producer of values), according to the semantics of the given strategy.Note
If
producer
or an active inner producer fails, the returned producer will forward that failure immediately.Warning
interrupted
events on inner producers will be treated likecompleted
events on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Error>
Parameters
strategy
Strategy 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
interrupted
events on inner producers will be treated likecompleted
events on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Value.Error>
Parameters
strategy
Strategy 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
interrupted
events on inner producers will be treated likecompleted
events on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Value.Error>
Parameters
strategy
Strategy 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
signal
fails, the returned signal will forward that failure immediately.Warning
interrupted
events on inner producers will be treated likecompleted
events on inner producers.Declaration
Swift
public func flatten(_ strategy: FlattenStrategy) -> SignalProducer<Value.Value, Error>
Parameters
strategy
Strategy used when flattening signals.
-
Flattens the
sequence
value sent bysignal
.Declaration
Swift
public func flatten() -> SignalProducer<Value.Iterator.Element, Error>
-
Maps each event from
self
to 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
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and returns a signal producer with transformed value. -
Maps each event from
self
to 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 == Error
Parameters
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and returns a signal producer with transformed value. -
Maps each event from
self
to 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
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and returns a signal producer with transformed value. -
Maps each event from
self
to 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
strategy
Strategy used when flattening signals.
transform
A closure that takes a value emitted by
self
and 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 : Sequence
Parameters
values
A sequence of values that a
Signal
will send as separatevalue
events 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
SignalProducer
that 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
operation
A failable closure.
-
Declaration
Swift
@discardableResult public func startWithValues(_ action: @escaping (Value) -> Void) -> Disposable
Parameters
action
A closure to be invoked with values from the produced
Signal
.Return Value
A disposable to interrupt the produced
Signal
.
-
Unwraps non-
nil
values and forwards them on the returned signal,nil
values 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
Event
values 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
self
events.
-
The inverse of materializeResults(), this will translate a producer of
Result
values into a producer of those events themselves.Declaration
Swift
public func dematerializeResults<Success, Failure>() -> SignalProducer<Success, Failure> where Value == Result<Success, Failure>, Failure : Error
Return Value
A producer that sends values carried by
self
results. -
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 : Error
Return 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
self
untilinterval
. Then if producer isn’t completed yet, fails witherror
onscheduler
.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
interval
Number of seconds to wait for
self
to complete.error
Error to send with
failed
event ifself
is not completed wheninterval
passes.scheudler
A scheduler to deliver error on.
Return Value
A producer that sends events for at most
interval
seconds, then, if notcompleted
- sendserror
withfailed
event 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 producedSignal
would propagate the failure and terminate.Declaration
Swift
public func attempt(_ action: @escaping (Value) throws -> Void) -> SignalProducer<Value, Swift.Error>
Parameters
action
A 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 producedSignal
would propagate the failure and terminate.Declaration
Swift
public func attemptMap<U>(_ action: @escaping (Value) throws -> U) -> SignalProducer<U, Swift.Error>
Parameters
action
A 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 producedSignal
would propagate the failure and terminate.Declaration
Swift
public func attempt(_ action: @escaping (Value) throws -> Void) -> SignalProducer<Value, Error>
Parameters
action
A 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 producedSignal
would propagate the failure and terminate.Declaration
Swift
public func attemptMap<U>(_ transform: @escaping (Value) throws -> U) -> SignalProducer<U, Error>
Parameters
transform
A 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
self
that 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
self
that 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
self
are ignored.Declaration
Swift
public func then<U, F>(_ replacement: SignalProducer<U, F>) -> SignalProducer<U, F> where F : Error
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Replacement.Error> where Replacement : SignalProducerConvertible
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<U>(_ replacement: SignalProducer<U, Never>) -> SignalProducer<U, Never>
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Replacement.Value, Never> where Replacement : SignalProducerConvertible, Replacement.Error == Never
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
.Note
All values sent from
self
are ignored.Declaration
Swift
public func then(_ replacement: SignalProducer<Value, Never>) -> SignalProducer<Value, Never>
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes. -
Wait for completion of
self
, then forward all events fromreplacement
.Note
All values sent from
self
are ignored.Declaration
Swift
public func then<Replacement>(_ replacement: Replacement) -> SignalProducer<Value, Never> where Value == Replacement.Value, Replacement : SignalProducerConvertible, Replacement.Error == Never
Parameters
replacement
A producer to start when
self
completes.Return Value
A producer that sends events from
self
and then fromreplacement
whenself
completes.
-
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
self
andproducer
.Declaration
Swift
public func and(_ booleans: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>
Parameters
booleans
A 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
self
andproducer
.Declaration
Swift
public func and<Booleans>(_ booleans: Booleans) -> SignalProducer<Value, Error> where Error == Booleans.Error, Booleans : SignalProducerConvertible, Booleans.Value == Bool
Parameters
booleans
A 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
booleans
A 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 == Bool
Parameters
booleans
A 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
self
andproducer
.Declaration
Swift
public func or(_ booleans: SignalProducer<Value, Error>) -> SignalProducer<Value, Error>
Parameters
booleans
A 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
self
andproducer
.Declaration
Swift
public func or<Booleans>(_ booleans: Booleans) -> SignalProducer<Value, Error> where Error == Booleans.Error, Booleans : SignalProducerConvertible, Booleans.Value == Bool
Parameters
booleans
A 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
booleans
A 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 == Bool
Parameters
booleans
A 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
interval
must be non-negative number.Note
If you plan to specify an
interval
value greater than 200,000 seconds, usetimer(interval:on:leeway:)
instead and specify your ownleeway
value to avoid potential overflow.Declaration
Swift
public static func timer(interval: DispatchTimeInterval, on scheduler: DateScheduler) -> SignalProducer<Value, Error>
Parameters
interval
An interval between invocations.
scheduler
A scheduler to deliver events on.
Return Value
A producer that sends
Date
values everyinterval
seconds. -
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
interval
must be non-negative number.Precondition
leeway
must be non-negative number.Declaration
Swift
public static func timer(interval: DispatchTimeInterval, on scheduler: DateScheduler, leeway: DispatchTimeInterval) -> SignalProducer<Value, Error>
Parameters
interval
An interval between invocations.
scheduler
A scheduler to deliver events on.
leeway
Interval 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
Date
values everyinterval
seconds.