ObservableType
public protocol ObservableType : ObservableConvertibleType
Represents a push style sequence.
-
subscribe(_:Default implementation) Subscribes
observerto receive events for this sequence.Grammar
Next* (Error | Completed)?
- sequences can produce zero or more elements so zero or more
Nextevents can be sent toobserver - once an
ErrororCompletedevent is sent, the sequence terminates and can’t produce any other elements
It is possible that events are sent from different threads, but no two events can be sent concurrently to
observer.Resource Management
When sequence sends
CompleteorErrorevent all internal resources that compute sequence elements will be freed.To cancel production of sequence elements and free resources immediately, call
disposeon returned subscription.Default Implementation
Subscribes an event handler to an observable sequence.
Declaration
Swift
func subscribe<Observer>(_ observer: Observer) -> Disposable where Observer : ObserverType, Self.Element == Observer.ElementReturn Value
Subscription for
observerthat can be used to cancel production of sequence elements and free resources. - sequences can produce zero or more elements so zero or more
-
subscribe(with:Extension methodonNext: onError: onCompleted: onDisposed: ) Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable 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
objectcan’t be retained, none of the other closures will be invoked.Declaration
Swift
public func subscribe<Object: AnyObject>( with object: Object, onNext: ((Object, Element) -> Void)? = nil, onError: ((Object, Swift.Error) -> Void)? = nil, onCompleted: ((Object) -> Void)? = nil, onDisposed: ((Object) -> Void)? = nil ) -> DisposableParameters
objectThe object to provide an unretained reference on.
onNextAction to invoke for each element in the observable sequence.
onErrorAction to invoke upon errored termination of the observable sequence.
onCompletedAction to invoke upon graceful termination of the observable sequence.
onDisposedAction 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(onNext:Extension methodonError: onCompleted: onDisposed: ) Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence.
Declaration
Swift
public func subscribe( onNext: ((Element) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil ) -> DisposableParameters
onNextAction to invoke for each element in the observable sequence.
onErrorAction to invoke upon errored termination of the observable sequence.
onCompletedAction to invoke upon graceful termination of the observable sequence.
onDisposedAction 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.
-
asObservable()Extension methodDefault implementation of converting
ObservableTypetoObservable.Declaration
Swift
public func asObservable() -> Observable<Element> -
amb(_:Extension method) Propagates the observable sequence that reacts first.
Seealso
Declaration
Swift
public static func amb<Sequence: Swift.Sequence>(_ sequence: Sequence) -> Observable<Element> where Sequence.Element == Observable<Element>Return Value
An observable sequence that surfaces any of the given sequences, whichever reacted first.
-
amb(_:Extension method) Propagates the observable sequence that reacts first.
Seealso
Declaration
Swift
public func amb<O2: ObservableType> (_ right: O2) -> Observable<Element> where O2.Element == ElementParameters
rightSecond observable sequence.
Return Value
An observable sequence that surfaces either of the given sequences, whichever reacted first.
-
buffer(timeSpan:Extension methodcount: scheduler: ) Projects each element of an observable sequence into a buffer that’s sent out when either it’s full or a given amount of time has elapsed, using the specified scheduler to run timers.
A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
Seealso
Declaration
Swift
public func buffer(timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) -> Observable<[Element]>Parameters
timeSpanMaximum time length of a buffer.
countMaximum element count of a buffer.
schedulerScheduler to run buffering timers on.
Return Value
An observable sequence of buffers.
-
catch(_:Extension method) Continues an observable sequence that is terminated by an error with the observable sequence produced by the handler.
Seealso
Declaration
Swift
public func `catch`(_ handler: @escaping (Swift.Error) throws -> Observable<Element>) -> Observable<Element>Parameters
handlerError handler function, producing another observable sequence.
Return Value
An observable sequence containing the source sequence’s elements, followed by the elements produced by the handler’s resulting observable sequence in case an error occurred.
-
catchError(_:Extension method) Continues an observable sequence that is terminated by an error with the observable sequence produced by the handler.
Seealso
Declaration
Swift
@available(*, deprecated, renamed: "catch(_:﹚") public func catchError(_ handler: @escaping (Swift.Error) throws -> Observable<Element>) -> Observable<Element>Parameters
handlerError handler function, producing another observable sequence.
Return Value
An observable sequence containing the source sequence’s elements, followed by the elements produced by the handler’s resulting observable sequence in case an error occurred.
-
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) -> Observable<Element>Parameters
elementLast element in an observable sequence in case error occurs.
Return Value
An observable sequence containing the source sequence’s elements, followed by the
elementin 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) -> Observable<Element>Parameters
elementLast element in an observable sequence in case error occurs.
Return Value
An observable sequence containing the source sequence’s elements, followed by the
elementin case an error occurred. -
catchError(_:Extension method) Continues an observable sequence that is terminated by an error with the next observable sequence.
Seealso
Declaration
Swift
@available(*, deprecated, renamed: "catch(onSuccess:onFailure:onDisposed:﹚") public static func catchError<Sequence: Swift.Sequence>(_ sequence: Sequence) -> Observable<Element> where Sequence.Element == Observable<Element>Return Value
An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
-
catch(sequence:Extension method) Continues an observable sequence that is terminated by an error with the next observable sequence.
Seealso
Declaration
Swift
public static func `catch`<Sequence: Swift.Sequence>(sequence: Sequence) -> Observable<Element> where Sequence.Element == Observable<Element>Return Value
An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
-
retry()Extension methodRepeats the source observable sequence until it successfully terminates.
This could potentially create an infinite sequence.
Seealso
Declaration
Swift
public func retry() -> Observable<Element>Return Value
Observable sequence to repeat until it successfully terminates.
-
retry(_:Extension method) Repeats the source observable sequence the specified number of times in case of an error or until it successfully terminates.
If you encounter an error and want it to retry once, then you must use
retry(2)Seealso
Declaration
Swift
public func retry(_ maxAttemptCount: Int) -> Observable<Element>Parameters
maxAttemptCountMaximum number of times to repeat the sequence.
Return Value
An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
-
combineLatest(_:Extension methodresultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<Collection: Swift.Collection>(_ collection: Collection, resultSelector: @escaping ([Collection.Element.Element]) throws -> Element) -> Observable<Element> where Collection.Element: ObservableTypeParameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
combineLatest(_:Extension method) Merges the specified observable sequences into one observable sequence whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<Collection: Swift.Collection>(_ collection: Collection) -> Observable<[Element]> where Collection.Element: ObservableType, Collection.Element.Element == ElementReturn Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:Extension method_: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType> (_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.Element, O2.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
combineLatest(_:Extension method_: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, resultSelector: @escaping (O1.Element, O2.Element, O3.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
combineLatest(_:Extension method_: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
combineLatest(_:Extension method_: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
combineLatest(_:Extension method_: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
combineLatest(_:Extension method_: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
combineLatest(_:Extension method_: _: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType, O8: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element, O8.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
compactMap(_:Extension method) Projects each element of an observable sequence into an optional form and filters all optional results.
Declaration
Swift
public func compactMap<Result>(_ transform: @escaping (Element) throws -> Result?) -> Observable<Result>Parameters
transformA transform function to apply to each source element and which returns an element or nil.
Return Value
An observable sequence whose elements are the result of filtering the transform function for each element of the source.
-
concat(_:Extension method) Concatenates the second observable sequence to
selfupon successful termination ofself.Seealso
Declaration
Swift
public func concat<Source>(_ second: Source) -> Observable<Element> where Source : ObservableConvertibleType, Self.Element == Source.ElementParameters
secondSecond 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.
This operator has tail recursive optimizations that will prevent stack overflow.
Optimizations will be performed in cases equivalent to following:
[1, [2, [3, …..].concat()].concat].concat()
Seealso
Declaration
Swift
public static func concat<Sequence: Swift.Sequence>(_ sequence: Sequence) -> Observable<Element> where Sequence.Element == Observable<Element>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 collection, as long as the previous observable sequence terminated successfully.
This operator has tail recursive optimizations that will prevent stack overflow.
Optimizations will be performed in cases equivalent to following:
[1, [2, [3, …..].concat()].concat].concat()
Seealso
Declaration
Swift
public static func concat<Collection: Swift.Collection>(_ collection: Collection) -> Observable<Element> where Collection.Element == Observable<Element>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 collection, as long as the previous observable sequence terminated successfully.
This operator has tail recursive optimizations that will prevent stack overflow.
Optimizations will be performed in cases equivalent to following:
[1, [2, [3, …..].concat()].concat].concat()
Seealso
Declaration
Swift
public static func concat(_ sources: Observable<Element>...) -> Observable<Element>Return Value
An observable sequence that contains the elements of each given sequence, in sequential order.
-
create(_:Extension method) Creates an observable sequence from a specified subscribe method implementation.
Seealso
Declaration
Swift
public static func create(_ subscribe: @escaping (AnyObserver<Element>) -> Disposable) -> Observable<Element>Parameters
subscribeImplementation of the resulting observable sequence’s
subscribemethod.Return Value
The observable sequence with the specified implementation for the
subscribemethod. -
debounce(_:Extension methodscheduler: ) Ignores elements from an observable sequence which are followed by another element within a specified relative time duration, using the specified scheduler to run throttling timers.
Declaration
Swift
public func debounce(_ dueTime: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
dueTimeThrottling duration for each element.
schedulerScheduler to run the throttle timers on.
Return Value
The throttled sequence.
-
debug(_:Extension methodtrimOutput: file: line: function: ) Prints received events for all observers on standard output.
Seealso
Declaration
Swift
public func debug(_ identifier: String? = nil, trimOutput: Bool = false, file: String = #file, line: UInt = #line, function: String = #function) -> Observable<Element>Parameters
identifierIdentifier that is printed together with event description to standard output.
trimOutputShould output be trimmed to max 40 characters.
Return Value
An observable sequence whose events are printed to standard output.
-
ifEmpty(default:Extension method) Emits elements from the source observable sequence, or a default element if the source observable sequence is empty.
Declaration
Swift
public func ifEmpty(default: Element) -> Observable<Element>Parameters
defaultDefault 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
-
deferred(_:Extension method) Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
Seealso
Declaration
Swift
public static func deferred(_ observableFactory: @escaping () throws -> Observable<Element>) -> Observable<Element>Parameters
observableFactoryObservable factory function to invoke for each observer that subscribes to the resulting sequence.
Return Value
An observable sequence whose observers trigger an invocation of the given observable factory function.
-
delay(_:Extension methodscheduler: ) Returns an observable sequence by the source observable sequence shifted forward in time by a specified delay. Error events from the source observable sequence are not delayed.
Seealso
Declaration
Swift
public func delay(_ dueTime: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
dueTimeRelative time shift of the source by.
schedulerScheduler to run the subscription delay timer on.
Return Value
the source Observable shifted in time by the specified delay.
-
delaySubscription(_:Extension methodscheduler: ) Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
Seealso
Declaration
Swift
public func delaySubscription(_ dueTime: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
dueTimeRelative time shift of the subscription.
schedulerScheduler to run the subscription delay timer on.
Return Value
Time-shifted sequence.
-
distinctUntilChanged(_:Extension method) Returns an observable sequence that contains only distinct contiguous elements according to the
keySelector.Declaration
Swift
public func distinctUntilChanged<Key: Equatable>(_ keySelector: @escaping (Element) throws -> Key) -> Observable<Element>Parameters
keySelectorA function to compute the comparison key for each element.
Return Value
An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.
-
distinctUntilChanged(_:Extension method) Returns an observable sequence that contains only distinct contiguous elements according to the
comparer.Declaration
Swift
public func distinctUntilChanged(_ comparer: @escaping (Element, Element) throws -> Bool) -> Observable<Element>Parameters
comparerEquality comparer for computed key values.
Return Value
An observable sequence only containing the distinct contiguous elements, based on
comparer, from the source sequence. -
distinctUntilChanged(_:Extension methodcomparer: ) Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
Declaration
Swift
public func distinctUntilChanged<K>(_ keySelector: @escaping (Element) throws -> K, comparer: @escaping (K, K) throws -> Bool) -> Observable<Element>Parameters
keySelectorA function to compute the comparison key for each element.
comparerEquality comparer for computed key values.
Return Value
An observable sequence only containing the distinct contiguous elements, based on a computed key value and the comparer, from the source sequence.
-
distinctUntilChanged(at:Extension method) Returns an observable sequence that contains only contiguous elements with distinct values in the provided key path on each object.
Declaration
Swift
public func distinctUntilChanged<Property: Equatable>(at keyPath: KeyPath<Element, Property>) -> Observable<Element>Return Value
An observable sequence only containing the distinct contiguous elements, based on equality operator on the provided key path
-
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) -> Observable<Element>Parameters
onNextAction to invoke for each element in the observable sequence.
afterNextAction to invoke for each element after the observable has passed an onNext event along to its downstream.
onErrorAction to invoke upon errored termination of the observable sequence.
afterErrorAction to invoke after errored termination of the observable sequence.
onCompletedAction to invoke upon graceful termination of the observable sequence.
afterCompletedAction to invoke after graceful termination of the observable sequence.
onSubscribeAction to invoke before subscribing to source observable sequence.
onSubscribedAction to invoke after subscribing to source observable sequence.
onDisposeAction 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.
-
elementAt(_:Extension method) Returns a sequence emitting only element n emitted by an Observable
Declaration
Swift
@available(*, deprecated, renamed: "element(at:﹚") public func elementAt(_ index: Int) -> Observable<Element>Parameters
indexThe index of the required element (starting from 0).
Return Value
An observable sequence that emits the desired element as its own sole emission.
-
element(at:Extension method) Returns a sequence emitting only element n emitted by an Observable
Declaration
Swift
public func element(at index: Int) -> Observable<Element>Parameters
indexThe index of the required element (starting from 0).
Return Value
An observable sequence that emits the desired element as its own sole emission.
-
empty()Extension methodReturns an empty observable sequence, using the specified scheduler to send out the single
Completedmessage.Seealso
Declaration
Swift
public static func empty() -> Observable<Element>Return Value
An observable sequence with no elements.
-
enumerated()Extension methodEnumerates the elements of an observable sequence.
Seealso
Declaration
Swift
public func enumerated() -> Observable<(index: Int, element: Element)>Return Value
An observable sequence that contains tuples of source sequence elements and their indexes.
-
error(_:Extension method) Returns an observable sequence that terminates with an
error.Seealso
Declaration
Swift
public static func error(_ error: Swift.Error) -> Observable<Element>Return Value
The observable sequence that terminates with specified error.
-
filter(_:Extension method) Filters the elements of an observable sequence based on a predicate.
Seealso
Declaration
Swift
public func filter(_ predicate: @escaping (Element) throws -> Bool) -> Observable<Element>Parameters
predicateA 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.
-
ignoreElements()Extension methodSkips elements and completes (or errors) when the observable sequence completes (or errors). Equivalent to filter that always returns false.
Declaration
Swift
public func ignoreElements() -> Observable<Never>Return Value
An observable sequence that skips all elements of the source sequence.
-
generate(initialState:Extension methodcondition: scheduler: iterate: ) Generates an observable sequence by running a state-driven loop producing the sequence’s elements, using the specified scheduler to run the loop send out observer messages.
Seealso
Declaration
Swift
public static func generate(initialState: Element, condition: @escaping (Element) throws -> Bool, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance, iterate: @escaping (Element) throws -> Element) -> Observable<Element>Parameters
initialStateInitial state.
conditionCondition to terminate generation (upon returning
false).iterateIteration step function.
schedulerScheduler on which to run the generator loop.
Return Value
The generated sequence.
-
groupBy(keySelector:Extension method) Undocumented
Declaration
Swift
public func groupBy<Key: Hashable>(keySelector: @escaping (Element) throws -> Key) -> Observable<GroupedObservable<Key, Element>> -
just(_:Extension method) Returns an observable sequence that contains a single element.
Seealso
Declaration
Swift
public static func just(_ element: Element) -> Observable<Element>Parameters
elementSingle 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) -> Observable<Element>Parameters
elementSingle element in the resulting observable sequence.
schedulerScheduler to send the single element on.
Return Value
An observable sequence containing the single specified element.
-
map(_:Extension method) Projects each element of an observable sequence into a new form.
Seealso
Declaration
Swift
public func map<Result>(_ transform: @escaping (Element) throws -> Result) -> Observable<Result>Parameters
transformA 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.
-
materialize()Extension methodConvert any Observable into an Observable of its events.
Declaration
Swift
public func materialize() -> Observable<Event<Element>>Return Value
An observable sequence that wraps events in an Event
. The returned Observable never errors, but it does complete after observing all of the events of the underlying Observable. -
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
Swift
public func flatMap<Source: ObservableConvertibleType>(_ selector: @escaping (Element) throws -> Source) -> Observable<Source.Element>Parameters
selectorA 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.
-
flatMapFirst(_:Extension method) Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. If element is received while there is some projected observable sequence being merged it will simply be ignored.
Declaration
Swift
public func flatMapFirst<Source: ObservableConvertibleType>(_ selector: @escaping (Element) throws -> Source) -> Observable<Source.Element>Parameters
selectorA transform function to apply to element that was observed while no observable is executing in parallel.
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 that was received while no other sequence was being calculated.
-
merge(_:Extension method) Merges elements from all observable sequences from collection into a single observable sequence.
Seealso
Declaration
Swift
public static func merge<Collection>(_ sources: Collection) -> Observable<Element> where Collection : Collection, Collection.Element == Observable<Self.Element>Parameters
sourcesCollection of observable sequences to merge.
Return Value
The observable sequence that merges the elements of the observable sequences.
-
merge(_:Extension method) Merges elements from all observable sequences from array into a single observable sequence.
Seealso
Declaration
Swift
public static func merge(_ sources: [Observable<Element>]) -> Observable<Element>Parameters
sourcesArray of observable sequences to merge.
Return Value
The observable sequence that merges the elements of the observable sequences.
-
merge(_:Extension method) Merges elements from all observable sequences into a single observable sequence.
Seealso
Declaration
Swift
public static func merge(_ sources: Observable<Element>...) -> Observable<Element>Parameters
sourcesCollection of observable sequences to merge.
Return Value
The observable sequence that merges the elements of the observable sequences.
-
concatMap(_:Extension method) Projects each element of an observable sequence to an observable sequence and concatenates the resulting observable sequences into one observable sequence.
Seealso
Declaration
Swift
public func concatMap<Source: ObservableConvertibleType>(_ selector: @escaping (Element) throws -> Source) -> Observable<Source.Element>Return Value
An observable sequence that contains the elements of each observed inner sequence, in sequential order.
-
multicast(_:Extension methodselector: ) Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function.
Each subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function’s invocation.
For specializations with fixed subject types, see
publishandreplay.Declaration
Swift
public func multicast<Subject: SubjectType, Result>(_ subjectSelector: @escaping () throws -> Subject, selector: @escaping (Observable<Subject.Element>) throws -> Observable<Result>) -> Observable<Result> where Subject.Observer.Element == ElementParameters
subjectSelectorFactory function to create an intermediate subject through which the source sequence’s elements will be multicast to the selector function.
selectorSelector function which can use the multicasted source sequence subject to the policies enforced by the created subject.
Return Value
An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
-
publish()Extension methodReturns a connectable observable sequence that shares a single subscription to the underlying sequence.
This operator is a specialization of
multicastusing aPublishSubject.Seealso
Declaration
Swift
public func publish() -> ConnectableObservable<Element>Return Value
A connectable observable sequence that shares a single subscription to the underlying sequence.
-
replay(_:Extension method) Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize elements.
This operator is a specialization of
multicastusing aReplaySubject.Seealso
Declaration
Swift
public func replay(_ bufferSize: Int) -> ConnectableObservable<Element>Parameters
bufferSizeMaximum element count of the replay buffer.
Return Value
A connectable observable sequence that shares a single subscription to the underlying sequence.
-
replayAll()Extension methodReturns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all elements.
This operator is a specialization of
multicastusing aReplaySubject.Seealso
Declaration
Swift
public func replayAll() -> ConnectableObservable<Element>Return Value
A connectable observable sequence that shares a single subscription to the underlying sequence.
-
multicast(_:Extension method) Multicasts the source sequence notifications through the specified subject to the resulting connectable observable.
Upon connection of the connectable observable, the subject is subscribed to the source exactly one, and messages are forwarded to the observers registered with the connectable observable.
For specializations with fixed subject types, see
publishandreplay.Declaration
Swift
public func multicast<Subject: SubjectType>(_ subject: Subject) -> ConnectableObservable<Subject.Element> where Subject.Observer.Element == ElementParameters
subjectSubject to push source elements into.
Return Value
A connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
-
multicast(makeSubject:Extension method) Multicasts the source sequence notifications through an instantiated subject to the resulting connectable observable.
Upon connection of the connectable observable, the subject is subscribed to the source exactly one, and messages are forwarded to the observers registered with the connectable observable.
Subject is cleared on connection disposal or in case source sequence produces terminal event.
Declaration
Swift
public func multicast<Subject: SubjectType>(makeSubject: @escaping () -> Subject) -> ConnectableObservable<Subject.Element> where Subject.Observer.Element == ElementParameters
makeSubjectFactory function used to instantiate a subject for each connection.
Return Value
A connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
-
never()Extension methodReturns a non-terminating observable sequence, which can be used to denote an infinite duration.
Seealso
Declaration
Swift
public static func never() -> Observable<Element>Return Value
An observable sequence whose observers will never get called.
-
observe(on:Extension method) Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
This only invokes observer callbacks on a
scheduler. In case the subscription and/or unsubscription actions have side-effects that require to be run on a scheduler, usesubscribeOn.Declaration
Swift
public func observe(on scheduler: ImmediateSchedulerType) -> Observable<Element>Parameters
schedulerScheduler to notify observers on.
Return Value
The source sequence whose observations happen on the specified scheduler.
-
observeOn(_:Extension method) Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
This only invokes observer callbacks on a
scheduler. In case the subscription and/or unsubscription actions have side-effects that require to be run on a scheduler, usesubscribeOn.Declaration
Swift
@available(*, deprecated, renamed: "observe(on:﹚") public func observeOn(_ scheduler: ImmediateSchedulerType) -> Observable<Element>Parameters
schedulerScheduler to notify observers on.
Return Value
The source sequence whose observations happen on the specified scheduler.
-
from(optional:Extension method) Converts a optional to an observable sequence.
Seealso
Declaration
Swift
public static func from(optional: Element?) -> Observable<Element>Parameters
optionalOptional element in the resulting observable sequence.
Return Value
An observable sequence containing the wrapped value or not from given optional.
-
from(optional:Extension methodscheduler: ) Converts a optional to an observable sequence.
Seealso
Declaration
Swift
public static func from(optional: Element?, scheduler: ImmediateSchedulerType) -> Observable<Element>Parameters
optionalOptional element in the resulting observable sequence.
schedulerScheduler to send the optional element on.
Return Value
An observable sequence containing the wrapped value or not from given optional.
-
reduce(_:Extension methodaccumulator: mapResult: ) Applies an
accumulatorfunction over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specifiedseedvalue is used as the initial accumulator value.For aggregation behavior with incremental intermediate results, see
scan.Seealso
Declaration
Swift
public func reduce<A, Result>(_ seed: A, accumulator: @escaping (A, Element) throws -> A, mapResult: @escaping (A) throws -> Result) -> Observable<Result>Parameters
seedThe initial accumulator value.
accumulatorA accumulator function to be invoked on each element.
mapResultA function to transform the final accumulator value into the result value.
Return Value
An observable sequence containing a single element with the final accumulator value.
-
reduce(_:Extension methodaccumulator: ) Applies an
accumulatorfunction over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specifiedseedvalue is used as the initial accumulator value.For aggregation behavior with incremental intermediate results, see
scan.Seealso
Declaration
Swift
public func reduce<A>(_ seed: A, accumulator: @escaping (A, Element) throws -> A) -> Observable<A>Parameters
seedThe initial accumulator value.
accumulatorA accumulator function to be invoked on each element.
Return Value
An observable sequence containing a single element with the final accumulator value.
-
repeatElement(_:Extension methodscheduler: ) Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
Seealso
Declaration
Swift
public static func repeatElement(_ element: Element, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element>Parameters
elementElement to repeat.
schedulerScheduler to run the producer loop on.
Return Value
An observable sequence that repeats the given element infinitely.
-
retry(when:Extension method) Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.
Seealso
Declaration
Swift
public func retry<TriggerObservable: ObservableType, Error: Swift.Error>(when notificationHandler: @escaping (Observable<Error>) -> TriggerObservable) -> Observable<Element>Parameters
notificationHandlerA handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.
Return Value
An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.
-
retryWhen(_:Extension method) Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.
Seealso
Declaration
Swift
@available(*, deprecated, renamed: "retry(when:﹚") public func retryWhen<TriggerObservable: ObservableType, Error: Swift.Error>(_ notificationHandler: @escaping (Observable<Error>) -> TriggerObservable) -> Observable<Element>Parameters
notificationHandlerA handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.
Return Value
An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.
-
retry(when:Extension method) Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.
Seealso
Declaration
Swift
public func retry<TriggerObservable: ObservableType>(when notificationHandler: @escaping (Observable<Swift.Error>) -> TriggerObservable) -> Observable<Element>Parameters
notificationHandlerA handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.
Return Value
An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.
-
retryWhen(_:Extension method) Repeats the source observable sequence on error when the notifier emits a next value. If the source observable errors and the notifier completes, it will complete the source sequence.
Seealso
Declaration
Swift
@available(*, deprecated, renamed: "retry(when:﹚") public func retryWhen<TriggerObservable: ObservableType>(_ notificationHandler: @escaping (Observable<Swift.Error>) -> TriggerObservable) -> Observable<Element>Parameters
notificationHandlerA handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable.
Return Value
An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete.
-
sample(_:Extension methoddefaultValue: ) Samples the source observable sequence using a sampler observable sequence producing sampling ticks.
Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
In case there were no new elements between sampler ticks, you may provide a default value to be emitted, instead to the resulting sequence otherwise no element is sent.
Seealso
Declaration
Swift
public func sample<Source: ObservableType>(_ sampler: Source, defaultValue: Element? = nil) -> Observable<Element>Parameters
samplerSampling tick sequence.
defaultValuea value to return if there are no new elements between sampler ticks
Return Value
Sampled observable sequence.
-
scan(into:Extension methodaccumulator: ) Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
For aggregation behavior with no intermediate results, see
reduce.Seealso
Declaration
Swift
public func scan<A>(into seed: A, accumulator: @escaping (inout A, Element) throws -> Void) -> Observable<A>Parameters
seedThe initial accumulator value.
accumulatorAn accumulator function to be invoked on each element.
Return Value
An observable sequence containing the accumulated values.
-
scan(_:Extension methodaccumulator: ) Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
For aggregation behavior with no intermediate results, see
reduce.Seealso
Declaration
Swift
public func scan<A>(_ seed: A, accumulator: @escaping (A, Element) throws -> A) -> Observable<A>Parameters
seedThe initial accumulator value.
accumulatorAn accumulator function to be invoked on each element.
Return Value
An observable sequence containing the accumulated values.
-
of(_:Extension methodscheduler: ) This method creates a new Observable instance with a variable number of elements.
Seealso
Declaration
Swift
public static func of(_ elements: Element..., scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element>Parameters
elementsElements to generate.
schedulerScheduler to send elements on. If
nil, elements are sent immediately on subscription.Return Value
The observable sequence whose elements are pulled from the given arguments.
-
from(_:Extension methodscheduler: ) Converts an array to an observable sequence.
Seealso
Declaration
Swift
public static func from(_ array: [Element], scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element>Return Value
The observable sequence whose elements are pulled from the given enumerable sequence.
-
from(_:Extension methodscheduler: ) Converts a sequence to an observable sequence.
Seealso
Declaration
Swift
public static func from<Sequence>(_ sequence: Sequence, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element> where Sequence : Sequence, Self.Element == Sequence.ElementReturn Value
The observable sequence whose elements are pulled from the given enumerable sequence.
-
share(replay:Extension methodscope: ) Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays elements in buffer.
This operator is equivalent to:
.whileConnected// Each connection will have it's own subject instance to store replay events. // Connections will be isolated from each another. source.multicast(makeSubject: { Replay.create(bufferSize: replay) }).refCount().forever// One subject will store replay events for all connections to source. // Connections won't be isolated from each another. source.multicast(Replay.create(bufferSize: replay)).refCount()
It uses optimized versions of the operators for most common operations.
Declaration
Swift
public func share(replay: Int = 0, scope: SubjectLifetimeScope = .whileConnected) -> Observable<Element>Parameters
replayMaximum element count of the replay buffer.
scopeLifetime scope of sharing subject. For more information see
SubjectLifetimeScopeenum.Return Value
An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
-
single()Extension methodThe single operator is similar to first, but throws a
RxError.noElementsorRxError.moreThanOneElementif the source Observable does not emit exactly one element before successfully completing.Seealso
Declaration
Swift
public func single() -> Observable<Element>Return Value
An observable sequence that emits a single element or throws an exception if more (or none) of them are emitted.
-
single(_:Extension method) The single operator is similar to first, but throws a
RxError.NoElementsorRxError.MoreThanOneElementif the source Observable does not emit exactly one element before successfully completing.Seealso
Declaration
Swift
public func single(_ predicate: @escaping (Element) throws -> Bool) -> Observable<Element>Parameters
predicateA function to test each source element for a condition.
Return Value
An observable sequence that emits a single element or throws an exception if more (or none) of them are emitted.
-
skip(_:Extension method) Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
Seealso
Declaration
Swift
public func skip(_ count: Int) -> Observable<Element>Parameters
countThe number of elements to skip before returning the remaining elements.
Return Value
An observable sequence that contains the elements that occur after the specified index in the input sequence.
-
skip(_:Extension methodscheduler: ) Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
Seealso
Declaration
Swift
public func skip(_ duration: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
durationDuration for skipping elements from the start of the sequence.
schedulerScheduler to run the timer on.
Return Value
An observable sequence with the elements skipped during the specified duration from the start of the source sequence.
-
skip(until:Extension method) Returns the elements from the source observable sequence that are emitted after the other observable sequence produces an element.
Declaration
Swift
public func skip<Source: ObservableType>(until other: Source) -> Observable<Element>Parameters
otherObservable sequence that starts propagation of elements of the source sequence.
Return Value
An observable sequence containing the elements of the source sequence that are emitted after the other sequence emits an item.
-
skipUntil(_:Extension method) Returns the elements from the source observable sequence that are emitted after the other observable sequence produces an element.
Declaration
Swift
@available(*, deprecated, renamed: "skip(until:﹚") public func skipUntil<Source: ObservableType>(_ other: Source) -> Observable<Element>Parameters
otherObservable sequence that starts propagation of elements of the source sequence.
Return Value
An observable sequence containing the elements of the source sequence that are emitted after the other sequence emits an item.
-
skip(while:Extension method) Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
Declaration
Swift
public func skip(while predicate: @escaping (Element) throws -> Bool) -> Observable<Element>Parameters
predicateA function to test each element for a condition.
Return Value
An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
-
skipWhile(_:Extension method) Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
Declaration
Swift
@available(*, deprecated, renamed: "skip(while:﹚") public func skipWhile(_ predicate: @escaping (Element) throws -> Bool) -> Observable<Element>Parameters
predicateA function to test each element for a condition.
Return Value
An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
-
startWith(_:Extension method) Prepends a sequence of values to an observable sequence.
Declaration
Swift
public func startWith(_ elements: Element ...) -> Observable<Element>Parameters
elementsElements to prepend to the specified sequence.
Return Value
The source sequence prepended with the specified values.
-
subscribe(on:Extension method) Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.
This operation is not commonly used.
This only performs the side-effects of subscription and unsubscription on the specified scheduler.
In order to invoke observer callbacks on a
scheduler, useobserveOn.Declaration
Swift
public func subscribe(on scheduler: ImmediateSchedulerType) -> Observable<Element>Parameters
schedulerScheduler to perform subscription and unsubscription actions on.
Return Value
The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
-
subscribeOn(_:Extension method) Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler.
This operation is not commonly used.
This only performs the side-effects of subscription and unsubscription on the specified scheduler.
In order to invoke observer callbacks on a
scheduler, useobserveOn.Declaration
Swift
@available(*, deprecated, renamed: "subscribe(on:﹚") public func subscribeOn(_ scheduler: ImmediateSchedulerType) -> Observable<Element>Parameters
schedulerScheduler to perform subscription and unsubscription actions on.
Return Value
The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.
-
flatMapLatest(_:Extension method) Projects each element of an observable sequence into a new sequence of observable sequences and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
It is a combination of
map+switchLatestoperatorDeclaration
Swift
public func flatMapLatest<Source: ObservableConvertibleType>(_ selector: @escaping (Element) throws -> Source) -> Observable<Source.Element>Parameters
selectorA transform function to apply to each element.
Return Value
An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
-
flatMapLatest(_:Extension method) Projects each element of an observable sequence into a new sequence of observable sequences and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
It is a combination of
map+switchLatestoperatorDeclaration
Swift
public func flatMapLatest<Source: InfallibleType>(_ selector: @escaping (Element) throws -> Source) -> Infallible<Source.Element>Parameters
selectorA transform function to apply to each element.
Return Value
An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences and that at any point in time produces the elements of the most recent inner observable sequence that has been received.
-
ifEmpty(switchTo:Extension method) Returns the elements of the specified sequence or
switchTosequence if the sequence is empty.Declaration
Swift
public func ifEmpty(switchTo other: Observable<Element>) -> Observable<Element>Parameters
otherObservable 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.
-
take(_:Extension method) Returns a specified number of contiguous elements from the start of an observable sequence.
Seealso
Declaration
Swift
public func take(_ count: Int) -> Observable<Element>Parameters
countThe number of elements to return.
Return Value
An observable sequence that contains the specified number of elements from the start of the input sequence.
-
take(for:Extension methodscheduler: ) Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
Seealso
Declaration
Swift
public func take(for duration: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
durationDuration for taking elements from the start of the sequence.
schedulerScheduler to run the timer on.
Return Value
An observable sequence with the elements taken during the specified duration from the start of the source sequence.
-
take(_:Extension methodscheduler: ) Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
Seealso
Declaration
Swift
@available(*, deprecated, renamed: "take(for:scheduler:﹚") public func take(_ duration: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
durationDuration for taking elements from the start of the sequence.
schedulerScheduler to run the timer on.
Return Value
An observable sequence with the elements taken during the specified duration from the start of the source sequence.
-
takeLast(_:Extension method) Returns a specified number of contiguous elements from the end of an observable sequence.
This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
Declaration
Swift
public func takeLast(_ count: Int) -> Observable<Element>Parameters
countNumber of elements to take from the end of the source sequence.
Return Value
An observable sequence containing the specified number of elements from the end of the source sequence.
-
take(until:Extension method) Returns the elements from the source observable sequence until the other observable sequence produces an element.
Declaration
Swift
public func take<Source: ObservableType>(until other: Source) -> Observable<Element>Parameters
otherObservable sequence that terminates propagation of elements of the source sequence.
Return Value
An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
-
take(until:Extension methodbehavior: ) Returns elements from an observable sequence until the specified condition is true.
Declaration
Swift
public func take(until predicate: @escaping (Element) throws -> Bool, behavior: TakeBehavior = .exclusive) -> Observable<Element>Parameters
predicateA function to test each element for a condition.
behaviorWhether or not to include the last element matching the predicate. Defaults to
exclusive.Return Value
An observable sequence that contains the elements from the input sequence that occur before the element at which the test passes.
-
take(while:Extension methodbehavior: ) Returns elements from an observable sequence as long as a specified condition is true.
Declaration
Swift
public func take(while predicate: @escaping (Element) throws -> Bool, behavior: TakeBehavior = .exclusive) -> Observable<Element>Parameters
predicateA function to test each element for a condition.
Return Value
An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
-
takeUntil(_:Extension method) Returns the elements from the source observable sequence until the other observable sequence produces an element.
Declaration
Swift
@available(*, deprecated, renamed: "take(until:﹚") public func takeUntil<Source: ObservableType>(_ other: Source) -> Observable<Element>Parameters
otherObservable sequence that terminates propagation of elements of the source sequence.
Return Value
An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
-
takeUntil(_:Extension methodpredicate: ) Returns elements from an observable sequence until the specified condition is true.
Declaration
Swift
@available(*, deprecated, renamed: "take(until:behavior:﹚") public func takeUntil(_ behavior: TakeBehavior, predicate: @escaping (Element) throws -> Bool) -> Observable<Element>Parameters
behaviorWhether or not to include the last element matching the predicate.
predicateA function to test each element for a condition.
Return Value
An observable sequence that contains the elements from the input sequence that occur before the element at which the test passes.
-
takeWhile(_:Extension method) Returns elements from an observable sequence as long as a specified condition is true.
Declaration
Swift
@available(*, deprecated, renamed: "take(while:﹚") public func takeWhile(_ predicate: @escaping (Element) throws -> Bool) -> Observable<Element>Parameters
predicateA function to test each element for a condition.
Return Value
An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
-
throttle(_:Extension methodlatest: scheduler: ) Returns an Observable that emits the first and the latest item emitted by the source Observable during sequential time windows of a specified duration.
This operator makes sure that no two elements are emitted in less then dueTime.
Declaration
Swift
public func throttle(_ dueTime: RxTimeInterval, latest: Bool = true, scheduler: SchedulerType) -> Observable<Element>Parameters
dueTimeThrottling duration for each element.
latestShould latest element received in a dueTime wide time window since last element emission be emitted.
schedulerScheduler to run the throttle timers on.
Return Value
The throttled sequence.
-
timeout(_:Extension methodscheduler: ) Applies a timeout policy for each element in the observable sequence. If the next element isn’t received within the specified timeout duration starting from its predecessor, a TimeoutError is propagated to the observer.
Seealso
Declaration
Swift
public func timeout(_ dueTime: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
dueTimeMaximum duration between values before a timeout occurs.
schedulerScheduler to run the timeout timer on.
Return Value
An observable sequence with a
RxError.timeoutin case of a timeout. -
timeout(_:Extension methodother: scheduler: ) Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers. If the next element isn’t received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
Seealso
Declaration
Swift
public func timeout<Source: ObservableConvertibleType>(_ dueTime: RxTimeInterval, other: Source, scheduler: SchedulerType) -> Observable<Element> where Element == Source.ElementParameters
dueTimeMaximum duration between values before a timeout occurs.
otherSequence to return in case of a timeout.
schedulerScheduler to run the timeout timer on.
Return Value
The source sequence switching to the other sequence in case of a timeout.
-
toArray()Extension methodConverts an Observable into a Single that emits the whole sequence as a single array and then terminates.
For aggregation behavior see
reduce.Seealso
Declaration
Swift
public func toArray() -> Single<[Element]>Return Value
A Single sequence containing all the emitted elements as array.
-
using(_:Extension methodobservableFactory: ) Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence’s lifetime.
Seealso
Declaration
Swift
public static func using<Resource>(_ resourceFactory: @escaping () throws -> Resource, observableFactory: @escaping (Resource) throws -> Observable<Element>) -> Observable<Element> where Resource : DisposableParameters
resourceFactoryFactory function to obtain a resource object.
observableFactoryFactory function to obtain an observable sequence that depends on the obtained resource.
Return Value
An observable sequence whose lifetime controls the lifetime of the dependent resource object.
-
window(timeSpan:Extension methodcount: scheduler: ) Projects each element of an observable sequence into a window that is completed when either it’s full or a given amount of time has elapsed.
Seealso
Declaration
Swift
public func window(timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) -> Observable<Observable<Element>>Parameters
timeSpanMaximum time length of a window.
countMaximum element count of a window.
schedulerScheduler to run windowing timers on.
Return Value
An observable sequence of windows (instances of
Observable). -
withLatestFrom(_:Extension methodresultSelector: ) Merges two observable sequences into one observable sequence by combining each element from self with the latest element from the second source, if any.
Note
Elements emitted by self before the second source has emitted any values will be omitted.
Declaration
Swift
public func withLatestFrom<Source, ResultType>(_ second: Source, resultSelector: @escaping (Element, Source.Element) throws -> ResultType) -> Observable<ResultType> where Source : ObservableConvertibleTypeParameters
secondSecond observable source.
resultSelectorFunction to invoke for each element from the self combined with the latest element from the second source, if any.
Return Value
An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function.
-
withLatestFrom(_:Extension method) Merges two observable sequences into one observable sequence by using latest element from the second sequence every time when
selfemits an element.Note
Elements emitted by self before the second source has emitted any values will be omitted.
Declaration
Swift
public func withLatestFrom<Source>(_ second: Source) -> Observable<Source.Element> where Source : ObservableConvertibleTypeParameters
secondSecond observable source.
Return Value
An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function.
-
withUnretained(_:Extension methodresultSelector: ) Provides an unretained, safe to use (i.e. not implicitly unwrapped), reference to an object along with the events emitted by the sequence.
In the case the provided object cannot be retained successfully, the sequence will complete.
Note
Be careful when using this operator in a sequence that has a buffer or replay, for example
share(replay: 1), as the sharing buffer will also include the provided object, which could potentially cause a retain cycle.Declaration
Swift
public func withUnretained<Object: AnyObject, Out>( _ obj: Object, resultSelector: @escaping (Object, Element) -> Out ) -> Observable<Out>Parameters
objThe object to provide an unretained reference on.
resultSelectorA function to combine the unretained referenced on
objand the value of the observable sequence.Return Value
An observable sequence that contains the result of
resultSelectorbeing called with an unretained reference onobjand the values of the original sequence. -
withUnretained(_:Extension method) Provides an unretained, safe to use (i.e. not implicitly unwrapped), reference to an object along with the events emitted by the sequence.
In the case the provided object cannot be retained successfully, the sequence will complete.
Note
Be careful when using this operator in a sequence that has a buffer or replay, for example
share(replay: 1), as the sharing buffer will also include the provided object, which could potentially cause a retain cycle.Declaration
Swift
public func withUnretained<Object>(_ obj: Object) -> Observable<(Object, Element)> where Object : AnyObjectParameters
objThe object to provide an unretained reference on.
Return Value
An observable sequence of tuples that contains both an unretained reference on
objand the values of the original 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.
Seealso
Declaration
Swift
public static func zip<Collection: Swift.Collection>(_ collection: Collection, resultSelector: @escaping ([Collection.Element.Element]) throws -> Element) -> Observable<Element> where Collection.Element: ObservableTypeParameters
resultSelectorFunction 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 whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<Collection: Swift.Collection>(_ collection: Collection) -> Observable<[Element]> where Collection.Element: ObservableType, Collection.Element.Element == ElementReturn Value
An observable sequence containing the result of combining elements of the sources.
-
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<O1: ObservableType, O2: ObservableType> (_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.Element, O2.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction 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_: _: 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<O1: ObservableType, O2: ObservableType, O3: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, resultSelector: @escaping (O1.Element, O2.Element, O3.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction 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_: _: _: 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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction 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_: _: _: _: 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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction 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_: _: _: _: _: 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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction 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_: _: _: _: _: _: 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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction 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_: _: _: _: _: _: _: 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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType, O8: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: @escaping (O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element, O8.Element) throws -> Element) -> Observable<Element>Parameters
resultSelectorFunction 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.
-
asSingle()Extension methodThe
asSingleoperator throws aRxError.noElementsorRxError.moreThanOneElementif the source Observable does not emit exactly one element before successfully completing.Seealso
Declaration
Swift
public func asSingle() -> Single<Element>Return Value
An observable sequence that emits a single element when the source Observable has completed, or throws an exception if more (or none) of them are emitted.
-
first()Extension methodThe
firstoperator emits only the very first item emitted by this Observable, or nil if this Observable completes without emitting anything.Seealso
Declaration
Swift
public func first() -> Single<Element?>Return Value
An observable sequence that emits a single element or nil if the source observable sequence completes without emitting any items.
-
asMaybe()Extension methodThe
asMaybeoperator throws aRxError.moreThanOneElementif the source Observable does not emit at most one element before successfully completing.Seealso
Declaration
Swift
public func asMaybe() -> Maybe<Element>Return Value
An observable sequence that emits a single element, completes when the source Observable has completed, or throws an exception if more of them are emitted.
-
combineLatest(_:Extension method_: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType> (_ source1: O1, _ source2: O2) -> Observable<(O1.Element, O2.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:Extension method_: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3) -> Observable<(O1.Element, O2.Element, O3.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:Extension method_: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:Extension method_: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:Extension method_: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:Extension method_: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:Extension method_: _: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType, O8: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element, O8.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
decode(type:Extension methoddecoder: ) Attempt to decode the emitted
Datausing a provided decoder.Note
If using a custom decoder, it must conform to the
DataDecoderprotocol.Declaration
Swift
func decode<Item: Decodable, Decoder: DataDecoder>(type: Item.Type, decoder: Decoder) -> Observable<Item>Parameters
typeA
Decodable-conforming type to attempt to decode todecoderA capable decoder, e.g.
JSONDecoderorPropertyListDecoderReturn Value
An
Observableof the decoded type
-
dematerialize()Extension methodConvert any previously materialized Observable into it’s original form.
Declaration
Swift
public func dematerialize() -> Observable<Element.Element>Return Value
The dematerialized observable sequence.
-
distinctUntilChanged()Extension methodReturns an observable sequence that contains only distinct contiguous elements according to equality operator.
Declaration
Swift
public func distinctUntilChanged() -> Observable<Element>Return Value
An observable sequence only containing the distinct contiguous elements, based on equality operator, from the source sequence.
-
merge()Extension methodMerges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
Seealso
Declaration
Swift
public func merge() -> Observable<Element.Element>Return Value
The observable sequence that merges the elements of the observable sequences.
-
merge(maxConcurrent:Extension method) Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
Seealso
Declaration
Swift
public func merge(maxConcurrent: Int) -> Observable<Element.Element>Parameters
maxConcurrentMaximum number of inner observable sequences being subscribed to concurrently.
Return Value
The observable sequence that merges the elements of the inner sequences.
-
concat()Extension methodConcatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.
Seealso
Declaration
Swift
public func concat() -> Observable<Element.Element>Return Value
An observable sequence that contains the elements of each observed inner sequence, in sequential order.
-
range(start:Extension methodcount: scheduler: ) Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to generate and send out observer messages.
Seealso
Declaration
Swift
public static func range(start: Element, count: Element, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element>Parameters
startThe value of the first integer in the sequence.
countThe number of sequential integers to generate.
schedulerScheduler to run the generator loop on.
Return Value
An observable sequence that contains a range of sequential integral numbers.
-
switchLatest()Extension methodTransforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
Each time a new inner observable sequence is received, unsubscribe from the previous inner observable sequence.
Seealso
Declaration
Swift
public func switchLatest() -> Observable<Element.Element>Return Value
The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.
-
interval(_:Extension methodscheduler: ) Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
Declaration
Swift
public static func interval(_ period: RxTimeInterval, scheduler: SchedulerType) -> Observable<Element>Parameters
periodPeriod for producing the values in the resulting sequence.
schedulerScheduler to run the timer on.
Return Value
An observable sequence that produces a value after each period.
-
timer(_:Extension methodperiod: scheduler: ) 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, period: RxTimeInterval? = nil, scheduler: SchedulerType) -> Observable<Element>Parameters
dueTimeRelative time at which to produce the first value.
periodPeriod to produce subsequent values.
schedulerScheduler to run timers on.
Return Value
An observable sequence that produces a value after due time has elapsed and then each period.
-
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<O1: ObservableType, O2: ObservableType> (_ source1: O1, _ source2: O2) -> Observable<(O1.Element, O2.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
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<O1: ObservableType, O2: ObservableType, O3: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3) -> Observable<(O1.Element, O2.Element, O3.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType, O8: ObservableType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8) -> Observable<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element, O8.Element)>Return Value
An observable sequence containing the result of combining elements of the sources.
-
asCompletable()Extension methodDeclaration
Swift
public func asCompletable() -> CompletableReturn Value
An observable sequence that completes.
View on GitHub
ObservableType Protocol Reference