PrimitiveSequenceType
public protocol PrimitiveSequenceType
Observable sequences containing 0 or 1 element
-
Additional constraints
Declaration
Swift
associatedtype Trait
-
Sequence element type
Declaration
Swift
associatedtype Element
-
Declaration
Swift
var primitiveSequence: PrimitiveSequence<Trait, Element> { get }
Return Value
Observable sequence that represents
self
.
-
andThen(_:
Extension method) Concatenates the second observable sequence to
self
upon successful termination ofself
.Seealso
Parameters
second
Second observable sequence.
Return Value
An observable sequence that contains the elements of
self
, followed by those of the second sequence. -
andThen(_:
Extension method) Concatenates the second observable sequence to
self
upon successful termination ofself
.Seealso
Parameters
second
Second observable sequence.
Return Value
An observable sequence that contains the elements of
self
, followed by those of the second sequence. -
andThen(_:
Extension method) Concatenates the second observable sequence to
self
upon successful termination ofself
.Seealso
Declaration
Swift
public func andThen(_ second: Completable) -> Completable
Parameters
second
Second observable sequence.
Return Value
An observable sequence that contains the elements of
self
, followed by those of the second sequence. -
andThen(_:
Extension method) Concatenates the second observable sequence to
self
upon successful termination ofself
.Seealso
Declaration
Swift
public func andThen<Element>(_ second: Observable<Element>) -> Observable<Element>
Parameters
second
Second observable sequence.
Return Value
An observable sequence that contains the elements of
self
, followed by those of the second sequence.
-
CompletableObserver
Extension methodUndocumented
Declaration
Swift
public typealias CompletableObserver = (CompletableEvent) -> Void
-
create(subscribe:
Extension method) Creates an observable sequence from a specified subscribe method implementation.
Seealso
Declaration
Swift
public static func create(subscribe: @escaping (@escaping CompletableObserver) -> Disposable) -> PrimitiveSequence<Trait, Element>
Parameters
subscribe
Implementation of the resulting observable sequence’s
subscribe
method.Return Value
The observable sequence with the specified implementation for the
subscribe
method. -
subscribe(_:
Extension method) Subscribes
observer
to receive events for this sequence.Declaration
Swift
public func subscribe(_ observer: @escaping (CompletableEvent) -> Void) -> Disposable
Return Value
Subscription for
observer
that can be used to cancel production of sequence elements and free resources. -
subscribe(with:
Extension methodonCompleted: onError: onDisposed: ) Subscribes a completion handler and an error handler for this sequence.
Also, take in an object and provide an unretained, safe to use (i.e. not implicitly unwrapped), reference to it along with the events emitted by the sequence.
Note
If
object
can’t be retained, none of the other closures will be invoked.Declaration
Swift
public func subscribe<Object: AnyObject>( with object: Object, onCompleted: ((Object) -> Void)? = nil, onError: ((Object, Swift.Error) -> Void)? = nil, onDisposed: ((Object) -> Void)? = nil ) -> Disposable
Parameters
object
The object to provide an unretained reference on.
onCompleted
Action to invoke upon graceful termination of the observable sequence.
onError
Action to invoke upon errored termination of the observable sequence.
onDisposed
Action to invoke upon any type of termination of sequence (if the sequence has gracefully completed, errored, or if the generation is canceled by disposing subscription).
Return Value
Subscription object used to unsubscribe from the observable sequence.
-
subscribe(onCompleted:
Extension methodonError: onDisposed: ) Subscribes a completion handler and an error handler for this sequence.
Declaration
Swift
public func subscribe(onCompleted: (() -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onDisposed: (() -> Void)? = nil) -> Disposable
Parameters
onCompleted
Action to invoke upon graceful termination of the observable sequence.
onError
Action to invoke upon errored termination of the observable sequence.
onDisposed
Action to invoke upon any type of termination of sequence (if the sequence has gracefully completed, errored, or if the generation is canceled by disposing subscription).
Return Value
Subscription object used to unsubscribe from the observable sequence.
-
error(_:
Extension method) Returns an observable sequence that terminates with an
error
.Seealso
Declaration
Swift
public static func error(_ error: Swift.Error) -> Completable
Return Value
The observable sequence that terminates with specified error.
-
never()
Extension methodReturns a non-terminating observable sequence, which can be used to denote an infinite duration.
Seealso
Declaration
Swift
public static func never() -> Completable
Return Value
An observable sequence whose observers will never get called.
-
empty()
Extension methodReturns an empty observable sequence, using the specified scheduler to send out the single
Completed
message.Seealso
Declaration
Swift
public static func empty() -> Completable
Return Value
An observable sequence with no elements.
-
do(onError:
Extension methodafterError: onCompleted: afterCompleted: onSubscribe: onSubscribed: onDispose: ) Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence.
Seealso
Declaration
Swift
public func `do`(onError: ((Swift.Error) throws -> Void)? = nil, afterError: ((Swift.Error) throws -> Void)? = nil, onCompleted: (() throws -> Void)? = nil, afterCompleted: (() throws -> Void)? = nil, onSubscribe: (() -> Void)? = nil, onSubscribed: (() -> Void)? = nil, onDispose: (() -> Void)? = nil) -> Completable
Parameters
onNext
Action to invoke for each element in the observable sequence.
onError
Action to invoke upon errored termination of the observable sequence.
afterError
Action to invoke after errored termination of the observable sequence.
onCompleted
Action to invoke upon graceful termination of the observable sequence.
afterCompleted
Action to invoke after graceful termination of the observable sequence.
onSubscribe
Action to invoke before subscribing to source observable sequence.
onSubscribed
Action to invoke after subscribing to source observable sequence.
onDispose
Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.
Return Value
The source sequence with the side-effecting behavior applied.
-
concat(_:
Extension method) Concatenates the second observable sequence to
self
upon successful termination ofself
.Seealso
Declaration
Swift
public func concat(_ second: Completable) -> Completable
Parameters
second
Second observable sequence.
Return Value
An observable sequence that contains the elements of
self
, followed by those of the second sequence. -
concat(_:
Extension method) Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully.
Seealso
Declaration
Swift
public static func concat<Sequence: Swift.Sequence>(_ sequence: Sequence) -> Completable where Sequence.Element == Completable
Return Value
An observable sequence that contains the elements of each given sequence, in sequential order.
-
concat(_:
Extension method) Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully.
Seealso
Declaration
Swift
public static func concat<Collection: Swift.Collection>(_ collection: Collection) -> Completable where Collection.Element == Completable
Return Value
An observable sequence that contains the elements of each given sequence, in sequential order.
-
concat(_:
Extension method) Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully.
Seealso
Declaration
Swift
public static func concat(_ sources: Completable...) -> Completable
Return Value
An observable sequence that contains the elements of each given sequence, in sequential order.
-
zip(_:
Extension method) Merges the completion of all Completables from a collection into a single Completable.
Seealso
merge operator on reactivex.ioNote
For
Completable
,zip
is an alias formerge
.Declaration
Swift
public static func zip<Collection: Swift.Collection>(_ sources: Collection) -> Completable where Collection.Element == Completable
Parameters
sources
Collection of Completables to merge.
Return Value
A Completable that merges the completion of all Completables.
-
zip(_:
Extension method) Merges the completion of all Completables from an array into a single Completable.
Seealso
merge operator on reactivex.ioNote
For
Completable
,zip
is an alias formerge
.Declaration
Swift
public static func zip(_ sources: [Completable]) -> Completable
Parameters
sources
Array of observable sequences to merge.
Return Value
A Completable that merges the completion of all Completables.
-
zip(_:
Extension method) Merges the completion of all Completables into a single Completable.
Seealso
merge operator on reactivex.ioNote
For
Completable
,zip
is an alias formerge
.Declaration
Swift
public static func zip(_ sources: Completable...) -> Completable
Parameters
sources
Collection of observable sequences to merge.
Return Value
The observable sequence that merges the elements of the observable sequences.
-
MaybeObserver
Extension methodUndocumented
Declaration
Swift
public typealias MaybeObserver = (MaybeEvent<Element>) -> Void
-
create(subscribe:
Extension method) Creates an observable sequence from a specified subscribe method implementation.
Seealso
Declaration
Swift
public static func create(subscribe: @escaping (@escaping MaybeObserver) -> Disposable) -> PrimitiveSequence<Trait, Element>
Parameters
subscribe
Implementation of the resulting observable sequence’s
subscribe
method.Return Value
The observable sequence with the specified implementation for the
subscribe
method. -
subscribe(_:
Extension method) Subscribes
observer
to receive events for this sequence.Declaration
Swift
public func subscribe(_ observer: @escaping (MaybeEvent<Element>) -> Void) -> Disposable
Return Value
Subscription for
observer
that can be used to cancel production of sequence elements and free resources. -
subscribe(with:
Extension methodonSuccess: onError: onCompleted: onDisposed: ) Subscribes a success handler, an error handler, and a completion handler for this sequence.
Also, take in an object and provide an unretained, safe to use (i.e. not implicitly unwrapped), reference to it along with the events emitted by the sequence.
Note
If
object
can’t be retained, none of the other closures will be invoked.Declaration
Swift
public func subscribe<Object: AnyObject>( with object: Object, onSuccess: ((Object, Element) -> Void)? = nil, onError: ((Object, Swift.Error) -> Void)? = nil, onCompleted: ((Object) -> Void)? = nil, onDisposed: ((Object) -> Void)? = nil ) -> Disposable
Parameters
object
The object to provide an unretained reference on.
onSuccess
Action to invoke for each element in the observable sequence.
onError
Action to invoke upon errored termination of the observable sequence.
onCompleted
Action to invoke upon graceful termination of the observable sequence.
onDisposed
Action to invoke upon any type of termination of sequence (if the sequence has gracefully completed, errored, or if the generation is canceled by disposing subscription).
Return Value
Subscription object used to unsubscribe from the observable sequence.
-
subscribe(onSuccess:
Extension methodonError: onCompleted: onDisposed: ) Subscribes a success handler, an error handler, and a completion handler for this sequence.
Declaration
Swift
public func subscribe(onSuccess: ((Element) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) -> Disposable
Parameters
onSuccess
Action to invoke for each element in the observable sequence.
onError
Action to invoke upon errored termination of the observable sequence.
onCompleted
Action to invoke upon graceful termination of the observable sequence.
onDisposed
Action to invoke upon any type of termination of sequence (if the sequence has gracefully completed, errored, or if the generation is canceled by disposing subscription).
Return Value
Subscription object used to unsubscribe from the observable sequence.
-
just(_:
Extension method) Returns an observable sequence that contains a single element.
Seealso
Parameters
element
Single element in the resulting observable sequence.
Return Value
An observable sequence containing the single specified element.
-
just(_:
Extension methodscheduler: ) Returns an observable sequence that contains a single element.
Seealso
Declaration
Swift
public static func just(_ element: Element, scheduler: ImmediateSchedulerType) -> Maybe<Element>
Parameters
element
Single element in the resulting observable sequence.
scheduler
Scheduler to send the single element on.
Return Value
An observable sequence containing the single specified element.
-
error(_:
Extension method) Returns an observable sequence that terminates with an
error
.Seealso
Return Value
The observable sequence that terminates with specified error.
-
never()
Extension methodReturns a non-terminating observable sequence, which can be used to denote an infinite duration.
Seealso
Return Value
An observable sequence whose observers will never get called.
-
empty()
Extension methodReturns an empty observable sequence, using the specified scheduler to send out the single
Completed
message.Seealso
Return Value
An observable sequence with no elements.
-
do(onNext:
Extension methodafterNext: onError: afterError: onCompleted: afterCompleted: onSubscribe: onSubscribed: onDispose: ) Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence.
Seealso
Declaration
Swift
public func `do`(onNext: ((Element) throws -> Void)? = nil, afterNext: ((Element) throws -> Void)? = nil, onError: ((Swift.Error) throws -> Void)? = nil, afterError: ((Swift.Error) throws -> Void)? = nil, onCompleted: (() throws -> Void)? = nil, afterCompleted: (() throws -> Void)? = nil, onSubscribe: (() -> Void)? = nil, onSubscribed: (() -> Void)? = nil, onDispose: (() -> Void)? = nil) -> Maybe<Element>
Parameters
onNext
Action to invoke for each element in the observable sequence.
afterNext
Action to invoke for each element after the observable has passed an onNext event along to its downstream.
onError
Action to invoke upon errored termination of the observable sequence.
afterError
Action to invoke after errored termination of the observable sequence.
onCompleted
Action to invoke upon graceful termination of the observable sequence.
afterCompleted
Action to invoke after graceful termination of the observable sequence.
onSubscribe
Action to invoke before subscribing to source observable sequence.
onSubscribed
Action to invoke after subscribing to source observable sequence.
onDispose
Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.
Return Value
The source sequence with the side-effecting behavior applied.
-
filter(_:
Extension method) Filters the elements of an observable sequence based on a predicate.
Seealso
Declaration
Parameters
predicate
A function to test each source element for a condition.
Return Value
An observable sequence that contains elements from the input sequence that satisfy the condition.
-
map(_:
Extension method) Projects each element of an observable sequence into a new form.
Seealso
Declaration
Parameters
transform
A transform function to apply to each source element.
Return Value
An observable sequence whose elements are the result of invoking the transform function on each element of source.
-
compactMap(_:
Extension method) Projects each element of an observable sequence into an optional form and filters all optional results.
Declaration
Parameters
transform
A transform function to apply to each source element.
Return Value
An observable sequence whose elements are the result of filtering the transform function for each element of the source.
-
flatMap(_:
Extension method) Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
Seealso
Declaration
Parameters
selector
A transform function to apply to each element.
Return Value
An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.
-
ifEmpty(default:
Extension method) Emits elements from the source observable sequence, or a default element if the source observable sequence is empty.
Parameters
default
Default element to be sent if the source does not emit any elements
Return Value
An observable sequence which emits default element end completes in case the original sequence is empty
-
ifEmpty(switchTo:
Extension method) Returns the elements of the specified sequence or
other
sequence if the sequence is empty.Parameters
other
Observable sequence being returned when source sequence is empty.
Return Value
Observable sequence that contains elements from switchTo sequence if source is empty, otherwise returns source sequence elements.
-
ifEmpty(switchTo:
Extension method) Returns the elements of the specified sequence or
other
sequence if the sequence is empty.Parameters
other
Observable sequence being returned when source sequence is empty.
Return Value
Observable sequence that contains elements from switchTo sequence if source is empty, otherwise returns source sequence elements.
-
catchAndReturn(_:
Extension method) Continues an observable sequence that is terminated by an error with a single element.
Seealso
Declaration
Swift
public func catchAndReturn(_ element: Element) -> PrimitiveSequence<Trait, Element>
Parameters
element
Last element in an observable sequence in case error occurs.
Return Value
An observable sequence containing the source sequence’s elements, followed by the
element
in case an error occurred. -
catchErrorJustReturn(_:
Extension method) Continues an observable sequence that is terminated by an error with a single element.
Seealso
Declaration
Swift
@available(*, deprecated, renamed: "catchAndReturn(_:﹚") public func catchErrorJustReturn(_ element: Element) -> PrimitiveSequence<Trait, Element>
Parameters
element
Last element in an observable sequence in case error occurs.
Return Value
An observable sequence containing the source sequence’s elements, followed by the
element
in case an error occurred.
-
create(detached:
Extension methodpriority: work: ) Creates a
Single
from the result of an asynchronous operationSeealso
Declaration
Swift
@_disfavoredOverload static func create( detached: Bool = false, priority: TaskPriority? = nil, work: @Sendable @escaping () async throws -> Element ) -> PrimitiveSequence<Trait, Element>
Parameters
work
An
async
closure expected to return an element of typeElement
Return Value
A
Single
of theasync
closure’s element type -
value
Extension method, asynchronous
-
value
Extension method, asynchronousAllows awaiting the success or failure of this
Maybe
asynchronously via Swift’s concurrency features (async/await
)If the
Maybe
completes without emitting a value, it would return anil
value to indicate so.A sample usage would look like so:
do { let value = try await maybe.value // Element? } catch { // Handle error }
Declaration
Swift
var value: Element? { get async throws }
-
value
Extension method, asynchronousAllows awaiting the success or failure of this
Completable
asynchronously via Swift’s concurrency features (async/await
)Upon completion, a
Void
will be returnedA sample usage would look like so:
do { let value = try await completable.value // Void } catch { // Handle error }
Declaration
Swift
var value: Void { get async throws }
-
zip(_:
Extension method_: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, resultSelector: @escaping (E1, E2) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>) -> PrimitiveSequence<Trait, (E1, E2)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, resultSelector: @escaping (E1, E2) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>) -> PrimitiveSequence<Trait, (E1, E2)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, resultSelector: @escaping (E1, E2, E3) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>) -> PrimitiveSequence<Trait, (E1, E2, E3)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, resultSelector: @escaping (E1, E2, E3) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>) -> PrimitiveSequence<Trait, (E1, E2, E3)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, resultSelector: @escaping (E1, E2, E3, E4) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, resultSelector: @escaping (E1, E2, E3, E4) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, resultSelector: @escaping (E1, E2, E3, E4, E5) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, resultSelector: @escaping (E1, E2, E3, E4, E5) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5, E6)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5, E6)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6, E7) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5, E6, E7)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6, E7) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5, E6, E7)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7, E8>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>, _ source8: PrimitiveSequence<Trait, E8>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6, E7, E8) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7, E8>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>, _ source8: PrimitiveSequence<Trait, E8>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5, E6, E7, E8)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7, E8>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>, _ source8: PrimitiveSequence<Trait, E8>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6, E7, E8) throws -> Element) -> PrimitiveSequence<Trait, Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method_: _: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7, E8>(_ source1: PrimitiveSequence<Trait, E1>, _ source2: PrimitiveSequence<Trait, E2>, _ source3: PrimitiveSequence<Trait, E3>, _ source4: PrimitiveSequence<Trait, E4>, _ source5: PrimitiveSequence<Trait, E5>, _ source6: PrimitiveSequence<Trait, E6>, _ source7: PrimitiveSequence<Trait, E7>, _ source8: PrimitiveSequence<Trait, E8>) -> PrimitiveSequence<Trait, (E1, E2, E3, E4, E5, E6, E7, E8)>
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
timer(_:
Extension methodscheduler: ) Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed, using the specified scheduler to run timers.
Seealso
Declaration
Swift
public static func timer(_ dueTime: RxTimeInterval, scheduler: SchedulerType) -> PrimitiveSequence<Trait, Element>
Parameters
dueTime
Relative time at which to produce the first value.
scheduler
Scheduler to run timers on.
Return Value
An observable sequence that produces a value after due time has elapsed and then each period.
-
SingleObserver
Extension methodUndocumented
Declaration
Swift
public typealias SingleObserver = (SingleEvent<Element>) -> Void
-
create(subscribe:
Extension method) Creates an observable sequence from a specified subscribe method implementation.
Seealso
Declaration
Swift
public static func create(subscribe: @escaping (@escaping SingleObserver) -> Disposable) -> Single<Element>
Parameters
subscribe
Implementation of the resulting observable sequence’s
subscribe
method.Return Value
The observable sequence with the specified implementation for the
subscribe
method. -
subscribe(_:
Extension method) Subscribes
observer
to receive events for this sequence.Declaration
Swift
public func subscribe(_ observer: @escaping (SingleEvent<Element>) -> Void) -> Disposable
Return Value
Subscription for
observer
that can be used to cancel production of sequence elements and free resources. -
subscribe(onSuccess:
Extension methodonError: onDisposed: ) Subscribes a success handler, and an error handler for this sequence.
Declaration
Swift
@available(*, deprecated, renamed: "subscribe(onSuccess:onFailure:onDisposed:﹚") public func subscribe(onSuccess: ((Element) -> Void)? = nil, onError: @escaping ((Swift.Error) -> Void), onDisposed: (() -> Void)? = nil) -> Disposable
Parameters
onSuccess
Action to invoke for each element in the observable sequence.
onError
Action to invoke upon errored termination of the observable sequence.
onDisposed
Action to invoke upon any type of termination of sequence (if the sequence has gracefully completed, errored, or if the generation is canceled by disposing subscription).
Return Value
Subscription object used to unsubscribe from the observable sequence.
-
subscribe(with:
Extension methodonSuccess: onFailure: onDisposed: ) Subscribes a success handler, and an error handler for this sequence.
Also, take in an object and provide an unretained, safe to use (i.e. not implicitly unwrapped), reference to it along with the events emitted by the sequence.
Note
If
object
can’t be retained, none of the other closures will be invoked.Declaration
Swift
public func subscribe<Object: AnyObject>( with object: Object, onSuccess: ((Object, Element) -> Void)? = nil, onFailure: ((Object, Swift.Error) -> Void)? = nil, onDisposed: ((Object) -> Void)? = nil ) -> Disposable
Parameters
object
The object to provide an unretained reference on.
onSuccess
Action to invoke for each element in the observable sequence.
onFailure
Action to invoke upon errored termination of the observable sequence.
onDisposed
Action to invoke upon any type of termination of sequence (if the sequence has gracefully completed, errored, or if the generation is canceled by disposing subscription).
Return Value
Subscription object used to unsubscribe from the observable sequence.
-
subscribe(onSuccess:
Extension methodonFailure: onDisposed: ) Subscribes a success handler, and an error handler for this sequence.
Declaration
Swift
public func subscribe(onSuccess: ((Element) -> Void)? = nil, onFailure: ((Swift.Error) -> Void)? = nil, onDisposed: (() -> Void)? = nil) -> Disposable
Parameters
onSuccess
Action to invoke for each element in the observable sequence.
onFailure
Action to invoke upon errored termination of the observable sequence.
onDisposed
Action to invoke upon any type of termination of sequence (if the sequence has gracefully completed, errored, or if the generation is canceled by disposing subscription).
Return Value
Subscription object used to unsubscribe from the observable sequence.
-
just(_:
Extension method) Returns an observable sequence that contains a single element.
Seealso
Parameters
element
Single element in the resulting observable sequence.
Return Value
An observable sequence containing the single specified element.
-
just(_:
Extension methodscheduler: ) Returns an observable sequence that contains a single element.
Seealso
Declaration
Swift
public static func just(_ element: Element, scheduler: ImmediateSchedulerType) -> Single<Element>
Parameters
element
Single element in the resulting observable sequence.
scheduler
Scheduler to send the single element on.
Return Value
An observable sequence containing the single specified element.
-
error(_:
Extension method) Returns an observable sequence that terminates with an
error
.Seealso
Return Value
The observable sequence that terminates with specified error.
-
never()
Extension methodReturns a non-terminating observable sequence, which can be used to denote an infinite duration.
Seealso
Return Value
An observable sequence whose observers will never get called.
-
Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence.
Seealso
Declaration
Swift
public func `do`(onSuccess: ((Element) throws -> Void)? = nil, afterSuccess: ((Element) throws -> Void)? = nil, onError: ((Swift.Error) throws -> Void)? = nil, afterError: ((Swift.Error) throws -> Void)? = nil, onSubscribe: (() -> Void)? = nil, onSubscribed: (() -> Void)? = nil, onDispose: (() -> Void)? = nil) -> Single<Element>
Parameters
onSuccess
Action to invoke for each element in the observable sequence.
afterSuccess
Action to invoke for each element after the observable has passed an onNext event along to its downstream.
onError
Action to invoke upon errored termination of the observable sequence.
afterError
Action to invoke after errored termination of the observable sequence.
onSubscribe
Action to invoke before subscribing to source observable sequence.
onSubscribed
Action to invoke after subscribing to source observable sequence.
onDispose
Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.
Return Value
The source sequence with the side-effecting behavior applied.
-
filter(_:
Extension method) Filters the elements of an observable sequence based on a predicate.
Seealso
Declaration
Parameters
predicate
A function to test each source element for a condition.
Return Value
An observable sequence that contains elements from the input sequence that satisfy the condition.
-
map(_:
Extension method) Projects each element of an observable sequence into a new form.
Seealso
Declaration
Parameters
transform
A transform function to apply to each source element.
Return Value
An observable sequence whose elements are the result of invoking the transform function on each element of source.
-
compactMap(_:
Extension method) Projects each element of an observable sequence into an optional form and filters all optional results.
Declaration
Parameters
transform
A transform function to apply to each source element.
Return Value
An observable sequence whose elements are the result of filtering the transform function for each element of the source.
-
flatMap(_:
Extension method) Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
Seealso
Declaration
Parameters
selector
A transform function to apply to each element.
Return Value
An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.
-
flatMapMaybe(_:
Extension method) Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
Seealso
Declaration
Parameters
selector
A transform function to apply to each element.
Return Value
An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.
-
flatMapCompletable(_:
Extension method) Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
Seealso
Declaration
Swift
public func flatMapCompletable(_ selector: @escaping (Element) throws -> Completable) -> Completable
Parameters
selector
A transform function to apply to each element.
Return Value
An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.
-
zip(_:
Extension methodresultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Declaration
Swift
public static func zip<Collection, Result>(_ collection: Collection, resultSelector: @escaping ([Element]) throws -> Result) -> PrimitiveSequence<Trait, Result> where Collection : Collection, Collection.Element == PrimitiveSequence<SingleTrait, Self.Element>
Parameters
resultSelector
Function to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
zip(_:
Extension method) Merges the specified observable sequences into one observable sequence all of the observable sequences have produced an element at a corresponding index.
Declaration
Swift
public static func zip<Collection>(_ collection: Collection) -> PrimitiveSequence<Trait, [Element]> where Collection : Collection, Collection.Element == PrimitiveSequence<SingleTrait, Self.Element>
Return Value
An observable sequence containing the result of combining elements of the sources.
-
catchAndReturn(_:
Extension method) Continues an observable sequence that is terminated by an error with a single element.
Seealso
Declaration
Swift
public func catchAndReturn(_ element: Element) -> PrimitiveSequence<Trait, Element>
Parameters
element
Last element in an observable sequence in case error occurs.
Return Value
An observable sequence containing the source sequence’s elements, followed by the
element
in case an error occurred. -
catchErrorJustReturn(_:
Extension method) Continues an observable sequence that is terminated by an error with a single element.
Seealso
Declaration
Swift
@available(*, deprecated, renamed: "catchAndReturn(_:﹚") public func catchErrorJustReturn(_ element: Element) -> PrimitiveSequence<Trait, Element>
Parameters
element
Last element in an observable sequence in case error occurs.
Return Value
An observable sequence containing the source sequence’s elements, followed by the
element
in case an error occurred. -
asMaybe()
Extension method -
asCompletable()
Extension methodConverts
self
toCompletable
trait, ignoring its emitted value if one exists.Declaration
Swift
public func asCompletable() -> Completable
Return Value
Completable trait that represents
self
.