Back to Rxswift

ObservableType

docs/Protocols/ObservableType.html

6.10.2127.9 KB
Original Source

ObservableType

public protocol ObservableType : ObservableConvertibleType

Represents a push style sequence.

`

                subscribe(_:)
                `

Subscribes observer to receive events for this sequence.

Grammar

Next* (Error | Completed)?

  • sequences can produce zero or more elements so zero or more Next events can be sent to observer
  • once an Error or Completed event 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 Complete or Error event all internal resources that compute sequence elements will be freed.

To cancel production of sequence elements and free resources immediately, call dispose on returned subscription.

Declaration

Swift

func subscribe<Observer>(_ observer: Observer) -> Disposable where Observer : ObserverType, Self.Element == Observer.Element

Return Value

Subscription for observer that can be used to cancel production of sequence elements and free resources.

`

                subscribe(_:)
                ` Extension method 

Subscribes an event handler to an observable sequence.

Declaration

Swift

func subscribe(_ on: @escaping (Event<Element>) -> Void) -> Disposable

Parameters

| on |

Action to invoke for each event in the observable sequence.

|

Return Value

Subscription object used to unsubscribe from the observable sequence.

`

                subscribe(with:onNext:onError:onCompleted:onDisposed:)
                ` Extension method 

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 object can’t be retained, none of the other closures will be invoked.

Declaration

Swift

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
) -> Disposable

Parameters

| object |

The object to provide an unretained reference on.

| | onNext |

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(onNext:onError:onCompleted:onDisposed:)
                ` Extension method 

Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence.

Declaration

Swift

func subscribe(
    onNext: ((Element) -> Void)? = nil,
    onError: ((Swift.Error) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable

Parameters

| onNext |

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.

`

                asObservable()
                ` Extension method 

Default implementation of converting ObservableType to Observable.

Declaration

Swift

func asObservable() -> Observable<Element>

`

                amb(_:)
                ` Extension method 

Propagates the observable sequence that reacts first.

Seealso

amb operator on reactivex.io

Declaration

Swift

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

amb operator on reactivex.io

Declaration

Swift

func amb<O2: ObservableType>
(_ right: O2)
    -> Observable<Element> where O2.Element == Element

Parameters

| right |

Second observable sequence.

|

Return Value

An observable sequence that surfaces either of the given sequences, whichever reacted first.

`

                buffer(timeSpan:count:scheduler:)
                ` Extension method 

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

buffer operator on reactivex.io

Declaration

Swift

func buffer(timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType)
    -> Observable<[Element]>

Parameters

| timeSpan |

Maximum time length of a buffer.

| | count |

Maximum element count of a buffer.

| | scheduler |

Scheduler 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

catch operator on reactivex.io

Declaration

Swift

func `catch`(_ handler: @escaping (Swift.Error) throws -> Observable<Element>)
    -> Observable<Element>

Parameters

| handler |

Error 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

catch operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "catch(_:﹚")
func catchError(_ handler: @escaping (Swift.Error) throws -> Observable<Element>)
    -> Observable<Element>

Parameters

| handler |

Error 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

catch operator on reactivex.io

Declaration

Swift

func catchAndReturn(_ element: Element)
    -> Observable<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

catch operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "catchAndReturn(_:﹚")
func catchErrorJustReturn(_ element: Element)
    -> Observable<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.

`

                catchError(_:)
                ` Extension method 

Continues an observable sequence that is terminated by an error with the next observable sequence.

Seealso

catch operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "catch(onSuccess:onFailure:onDisposed:﹚")
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

catch operator on reactivex.io

Declaration

Swift

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 method 

Repeats the source observable sequence until it successfully terminates.

This could potentially create an infinite sequence.

Seealso

retry operator on reactivex.io

Declaration

Swift

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

retry operator on reactivex.io

Declaration

Swift

func retry(_ maxAttemptCount: Int)
    -> Observable<Element>

Parameters

| maxAttemptCount |

Maximum 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(_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combinelatest operator on reactivex.io

Declaration

Swift

static func combineLatest<Collection: Swift.Collection>(_ collection: Collection, resultSelector: @escaping ([Collection.Element.Element]) throws -> Element) -> Observable<Element>
    where Collection.Element: ObservableType

Parameters

| resultSelector |

Function 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.

Seealso

combinelatest operator on reactivex.io

Declaration

Swift

static func combineLatest<Collection: Swift.Collection>(_ collection: Collection) -> Observable<[Element]>
    where Collection.Element: ObservableType, Collection.Element.Element == Element

Return Value

An observable sequence containing the result of combining elements of the sources.

`

                combineLatest(_:_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

static func combineLatest<O1: ObservableType, O2: ObservableType>
(_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.Element, O2.Element) throws -> Element)
    -> Observable<Element>

Parameters

| resultSelector |

Function 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(_:_:_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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

| resultSelector |

Function 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(_:_:_:_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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

| resultSelector |

Function 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(_:_:_:_:_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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

| resultSelector |

Function 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(_:_:_:_:_:_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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

| resultSelector |

Function 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(_:_:_:_:_:_:_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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

| resultSelector |

Function 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(_:_:_:_:_:_:_:_:resultSelector:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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

| resultSelector |

Function 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

func compactMap<Result>(_ transform: @escaping (Element) throws -> Result?)
    -> Observable<Result>

Parameters

| transform |

A 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 self upon successful termination of self.

Seealso

concat operator on reactivex.io

Declaration

Swift

func concat<Source>(_ second: Source) -> Observable<Element> where Source : ObservableConvertibleType, Self.Element == Source.Element

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.

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

concat operator on reactivex.io

Declaration

Swift

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

concat operator on reactivex.io

Declaration

Swift

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

concat operator on reactivex.io

Declaration

Swift

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

`

                create(_:)
                ` Extension method 

Creates an observable sequence from a specified subscribe method implementation.

Seealso

create operator on reactivex.io

Declaration

Swift

static func create(_ subscribe: @escaping (AnyObserver<Element>) -> Disposable) -> Observable<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.

`

                debounce(_:scheduler:)
                ` Extension method 

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.

Seealso

debounce operator on reactivex.io

Declaration

Swift

func debounce(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| dueTime |

Throttling duration for each element.

| | scheduler |

Scheduler to run the throttle timers on.

|

Return Value

The throttled sequence.

`

                debug(_:trimOutput:file:line:function:)
                ` Extension method 

Prints received events for all observers on standard output.

Seealso

do operator on reactivex.io

Declaration

Swift

func debug(_ identifier: String? = nil, trimOutput: Bool = false, file: String = #file, line: UInt = #line, function: String = #function)
    -> Observable<Element>

Parameters

| identifier |

Identifier that is printed together with event description to standard output.

| | trimOutput |

Should 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.

Seealso

DefaultIfEmpty operator on reactivex.io

Declaration

Swift

func ifEmpty(default: Element) -> Observable<Element>

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

`

                deferred(_:)
                ` Extension method 

Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.

Seealso

defer operator on reactivex.io

Declaration

Swift

static func deferred(_ observableFactory: @escaping () throws -> Observable<Element>)
    -> Observable<Element>

Parameters

| observableFactory |

Observable 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(_:scheduler:)
                ` Extension method 

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

delay operator on reactivex.io

Declaration

Swift

func delay(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| dueTime |

Relative time shift of the source by.

| | scheduler |

Scheduler to run the subscription delay timer on.

|

Return Value

the source Observable shifted in time by the specified delay.

`

                delaySubscription(_:scheduler:)
                ` Extension method 

Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.

Seealso

delay operator on reactivex.io

Declaration

Swift

func delaySubscription(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| dueTime |

Relative time shift of the subscription.

| | scheduler |

Scheduler 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.

Seealso

distinct operator on reactivex.io

Declaration

Swift

func distinctUntilChanged(_ keySelector: @escaping (Element) throws -> some Equatable)
    -> Observable<Element>

Parameters

| keySelector |

A 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.

Seealso

distinct operator on reactivex.io

Declaration

Swift

func distinctUntilChanged(_ comparer: @escaping (Element, Element) throws -> Bool)
    -> Observable<Element>

Parameters

| comparer |

Equality comparer for computed key values.

|

Return Value

An observable sequence only containing the distinct contiguous elements, based on comparer, from the source sequence.

`

                distinctUntilChanged(_:comparer:)
                ` Extension method 

Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.

Seealso

distinct operator on reactivex.io

Declaration

Swift

func distinctUntilChanged<K>(_ keySelector: @escaping (Element) throws -> K, comparer: @escaping (K, K) throws -> Bool)
    -> Observable<Element>

Parameters

| keySelector |

A function to compute the comparison key for each element.

| | comparer |

Equality 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.

Seealso

distinct operator on reactivex.io

Declaration

Swift

func distinctUntilChanged(at keyPath: KeyPath<Element, some Equatable>) ->
    Observable<Element>

Return Value

An observable sequence only containing the distinct contiguous elements, based on equality operator on the provided key path

`

                do(onNext:afterNext:onError:afterError:onCompleted:afterCompleted:onSubscribe:onSubscribed:onDispose:)
                ` Extension method 

Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence.

Seealso

do operator on reactivex.io

Declaration

Swift

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

| 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.

`

                elementAt(_:)
                ` Extension method 

Returns a sequence emitting only element n emitted by an Observable

Seealso

elementAt operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "element(at:﹚")
func elementAt(_ index: Int)
    -> Observable<Element>

Parameters

| index |

The 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

Seealso

elementAt operator on reactivex.io

Declaration

Swift

func element(at index: Int)
    -> Observable<Element>

Parameters

| index |

The 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 method 

Returns an empty observable sequence, using the specified scheduler to send out the single Completed message.

Seealso

empty operator on reactivex.io

Declaration

Swift

static func empty() -> Observable<Element>

Return Value

An observable sequence with no elements.

`

                enumerated()
                ` Extension method 

Enumerates the elements of an observable sequence.

Seealso

map operator on reactivex.io

Declaration

Swift

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

throw operator on reactivex.io

Declaration

Swift

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

filter operator on reactivex.io

Declaration

Swift

func filter(_ predicate: @escaping (Element) throws -> Bool)
    -> Observable<Element>

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.

`

                ignoreElements()
                ` Extension method 

Skips elements and completes (or errors) when the observable sequence completes (or errors). Equivalent to filter that always returns false.

Seealso

ignoreElements operator on reactivex.io

Declaration

Swift

func ignoreElements()
    -> Observable<Never>

Return Value

An observable sequence that skips all elements of the source sequence.

`

                generate(initialState:condition:scheduler:iterate:)
                ` Extension method 

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

create operator on reactivex.io

Declaration

Swift

static func generate(initialState: Element, condition: @escaping (Element) throws -> Bool, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance, iterate: @escaping (Element) throws -> Element) -> Observable<Element>

Parameters

| initialState |

Initial state.

| | condition |

Condition to terminate generation (upon returning false).

| | iterate |

Iteration step function.

| | scheduler |

Scheduler on which to run the generator loop.

|

Return Value

The generated sequence.

`

                groupBy(keySelector:)
                ` Extension method 

Undocumented

Declaration

Swift

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

just operator on reactivex.io

Declaration

Swift

static func just(_ element: Element) -> Observable<Element>

Parameters

| element |

Single element in the resulting observable sequence.

|

Return Value

An observable sequence containing the single specified element.

`

                just(_:scheduler:)
                ` Extension method 

Returns an observable sequence that contains a single element.

Seealso

just operator on reactivex.io

Declaration

Swift

static func just(_ element: Element, scheduler: ImmediateSchedulerType) -> Observable<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.

`

                map(_:)
                ` Extension method 

Projects each element of an observable sequence into a new form.

Seealso

map operator on reactivex.io

Declaration

Swift

func map<Result>(_ transform: @escaping (Element) throws -> Result)
    -> Observable<Result>

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.

`

                materialize()
                ` Extension method 

Convert any Observable into an Observable of its events.

Seealso

materialize operator on reactivex.io

Declaration

Swift

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

flatMap operator on reactivex.io

Declaration

Swift

func flatMap<Source: ObservableConvertibleType>(_ selector: @escaping (Element) throws -> Source)
    -> Observable<Source.Element>

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.

`

                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.

Seealso

flatMapFirst operator on reactivex.io

Declaration

Swift

func flatMapFirst<Source: ObservableConvertibleType>(_ selector: @escaping (Element) throws -> Source)
    -> Observable<Source.Element>

Parameters

| selector |

A 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

merge operator on reactivex.io

Declaration

Swift

static func merge<Collection>(_ sources: Collection) -> Observable<Element> where Collection : Collection, Collection.Element == Observable<Self.Element>

Parameters

| sources |

Collection 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

merge operator on reactivex.io

Declaration

Swift

static func merge(_ sources: [Observable<Element>]) -> Observable<Element>

Parameters

| sources |

Array 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

merge operator on reactivex.io

Declaration

Swift

static func merge(_ sources: Observable<Element>...) -> Observable<Element>

Parameters

| sources |

Collection of observable sequences to merge.

|

Return Value

The observable sequence that merges the elements of the observable sequences.

concatMap

`

                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

concat operator on reactivex.io

Declaration

Swift

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(_:selector:)
                ` Extension method 

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 publish and replay.

Seealso

multicast operator on reactivex.io

Declaration

Swift

func multicast<Subject: SubjectType, Result>(_ subjectSelector: @escaping () throws -> Subject, selector: @escaping (Observable<Subject.Element>) throws -> Observable<Result>)
    -> Observable<Result> where Subject.Observer.Element == Element

Parameters

| subjectSelector |

Factory function to create an intermediate subject through which the source sequence’s elements will be multicast to the selector function.

| | selector |

Selector 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 method 

Returns a connectable observable sequence that shares a single subscription to the underlying sequence.

This operator is a specialization of multicast using a PublishSubject.

Seealso

publish operator on reactivex.io

Declaration

Swift

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 multicast using a ReplaySubject.

Seealso

replay operator on reactivex.io

Declaration

Swift

func replay(_ bufferSize: Int)
    -> ConnectableObservable<Element>

Parameters

| bufferSize |

Maximum element count of the replay buffer.

|

Return Value

A connectable observable sequence that shares a single subscription to the underlying sequence.

`

                replayAll()
                ` Extension method 

Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all elements.

This operator is a specialization of multicast using a ReplaySubject.

Seealso

replay operator on reactivex.io

Declaration

Swift

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 publish and replay.

Seealso

multicast operator on reactivex.io

Declaration

Swift

func multicast<Subject: SubjectType>(_ subject: Subject)
    -> ConnectableObservable<Subject.Element> where Subject.Observer.Element == Element

Parameters

| subject |

Subject 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.

Seealso

multicast operator on reactivex.io

Declaration

Swift

func multicast<Subject: SubjectType>(makeSubject: @escaping () -> Subject)
    -> ConnectableObservable<Subject.Element> where Subject.Observer.Element == Element

Parameters

| makeSubject |

Factory 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 method 

Returns a non-terminating observable sequence, which can be used to denote an infinite duration.

Seealso

never operator on reactivex.io

Declaration

Swift

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, use subscribeOn.

Seealso

observeOn operator on reactivex.io

Declaration

Swift

func observe(on scheduler: ImmediateSchedulerType)
    -> Observable<Element>

Parameters

| scheduler |

Scheduler 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, use subscribeOn.

Seealso

observeOn operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "observe(on:﹚")
func observeOn(_ scheduler: ImmediateSchedulerType)
    -> Observable<Element>

Parameters

| scheduler |

Scheduler 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

from operator on reactivex.io

Declaration

Swift

static func from(optional: Element?) -> Observable<Element>

Parameters

| optional |

Optional element in the resulting observable sequence.

|

Return Value

An observable sequence containing the wrapped value or not from given optional.

`

                from(optional:scheduler:)
                ` Extension method 

Converts a optional to an observable sequence.

Seealso

from operator on reactivex.io

Declaration

Swift

static func from(optional: Element?, scheduler: ImmediateSchedulerType) -> Observable<Element>

Parameters

| optional |

Optional element in the resulting observable sequence.

| | scheduler |

Scheduler to send the optional element on.

|

Return Value

An observable sequence containing the wrapped value or not from given optional.

`

                reduce(_:accumulator:mapResult:)
                ` Extension method 

Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.

For aggregation behavior with incremental intermediate results, see scan.

Seealso

reduce operator on reactivex.io

Declaration

Swift

func reduce<A, Result>(_ seed: A, accumulator: @escaping (A, Element) throws -> A, mapResult: @escaping (A) throws -> Result)
    -> Observable<Result>

Parameters

| seed |

The initial accumulator value.

| | accumulator |

A accumulator function to be invoked on each element.

| | mapResult |

A 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(_:accumulator:)
                ` Extension method 

Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.

For aggregation behavior with incremental intermediate results, see scan.

Seealso

reduce operator on reactivex.io

Declaration

Swift

func reduce<A>(_ seed: A, accumulator: @escaping (A, Element) throws -> A)
    -> Observable<A>

Parameters

| seed |

The initial accumulator value.

| | accumulator |

A accumulator function to be invoked on each element.

|

Return Value

An observable sequence containing a single element with the final accumulator value.

`

                repeatElement(_:scheduler:)
                ` Extension method 

Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.

Seealso

repeat operator on reactivex.io

Declaration

Swift

static func repeatElement(_ element: Element, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element>

Parameters

| element |

Element to repeat.

| | scheduler |

Scheduler 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

retry operator on reactivex.io

Declaration

Swift

func retry<Error: Swift.Error>(when notificationHandler: @escaping (Observable<Error>) -> some ObservableType)
    -> Observable<Element>

Parameters

| notificationHandler |

A 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

retry operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "retry(when:﹚")
func retryWhen<Error: Swift.Error>(_ notificationHandler: @escaping (Observable<Error>) -> some ObservableType)
    -> Observable<Element>

Parameters

| notificationHandler |

A 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

retry operator on reactivex.io

Declaration

Swift

func retry(when notificationHandler: @escaping (Observable<Swift.Error>) -> some ObservableType)
    -> Observable<Element>

Parameters

| notificationHandler |

A 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

retry operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "retry(when:﹚")
func retryWhen(_ notificationHandler: @escaping (Observable<Swift.Error>) -> some ObservableType)
    -> Observable<Element>

Parameters

| notificationHandler |

A 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(_:defaultValue:)
                ` Extension method 

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

sample operator on reactivex.io

Declaration

Swift

func sample(_ sampler: some ObservableType, defaultValue: Element? = nil)
    -> Observable<Element>

Parameters

| sampler |

Sampling tick sequence.

| | defaultValue |

a value to return if there are no new elements between sampler ticks

|

Return Value

Sampled observable sequence.

`

                scan(into:accumulator:)
                ` Extension method 

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

scan operator on reactivex.io

Declaration

Swift

func scan<A>(into seed: A, accumulator: @escaping (inout A, Element) throws -> Void)
    -> Observable<A>

Parameters

| seed |

The initial accumulator value.

| | accumulator |

An accumulator function to be invoked on each element.

|

Return Value

An observable sequence containing the accumulated values.

`

                scan(_:accumulator:)
                ` Extension method 

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

scan operator on reactivex.io

Declaration

Swift

func scan<A>(_ seed: A, accumulator: @escaping (A, Element) throws -> A)
    -> Observable<A>

Parameters

| seed |

The initial accumulator value.

| | accumulator |

An accumulator function to be invoked on each element.

|

Return Value

An observable sequence containing the accumulated values.

of

`

                of(_:scheduler:)
                ` Extension method 

This method creates a new Observable instance with a variable number of elements.

Seealso

from operator on reactivex.io

Declaration

Swift

static func of(_ elements: Element..., scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element>

Parameters

| elements |

Elements to generate.

| | scheduler |

Scheduler 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(_:scheduler:)
                ` Extension method 

Converts an array to an observable sequence.

Seealso

from operator on reactivex.io

Declaration

Swift

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(_:scheduler:)
                ` Extension method 

Converts a sequence to an observable sequence.

Seealso

from operator on reactivex.io

Declaration

Swift

static func from<Sequence>(_ sequence: Sequence, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element> where Sequence : Sequence, Self.Element == Sequence.Element

Return Value

The observable sequence whose elements are pulled from the given enumerable sequence.

`

                share(replay:scope:)
                ` Extension method 

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.

Seealso

shareReplay operator on reactivex.io

Declaration

Swift

func share(replay: Int = 0, scope: SubjectLifetimeScope = .whileConnected)
    -> Observable<Element>

Parameters

| replay |

Maximum element count of the replay buffer.

| | scope |

Lifetime scope of sharing subject. For more information see SubjectLifetimeScope enum.

|

Return Value

An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.

`

                single()
                ` Extension method 

The single operator is similar to first, but throws a RxError.noElements or RxError.moreThanOneElement if the source Observable does not emit exactly one element before successfully completing.

Seealso

single operator on reactivex.io

Declaration

Swift

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.NoElements or RxError.MoreThanOneElement if the source Observable does not emit exactly one element before successfully completing.

Seealso

single operator on reactivex.io

Declaration

Swift

func single(_ predicate: @escaping (Element) throws -> Bool)
    -> Observable<Element>

Parameters

| predicate |

A 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

skip operator on reactivex.io

Declaration

Swift

func skip(_ count: Int)
    -> Observable<Element>

Parameters

| count |

The 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(_:scheduler:)
                ` Extension method 

Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.

Seealso

skip operator on reactivex.io

Declaration

Swift

func skip(_ duration: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| duration |

Duration for skipping elements from the start of the sequence.

| | scheduler |

Scheduler 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.

Seealso

skipUntil operator on reactivex.io

Declaration

Swift

func skip(until other: some ObservableType)
    -> Observable<Element>

Parameters

| other |

Observable 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.

Seealso

skipUntil operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "skip(until:﹚")
func skipUntil(_ other: some ObservableType)
    -> Observable<Element>

Parameters

| other |

Observable 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.

Seealso

skipWhile operator on reactivex.io

Declaration

Swift

func skip(while predicate: @escaping (Element) throws -> Bool) -> Observable<Element>

Parameters

| predicate |

A 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.

Seealso

skipWhile operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "skip(while:﹚")
func skipWhile(_ predicate: @escaping (Element) throws -> Bool) -> Observable<Element>

Parameters

| predicate |

A 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.

Seealso

startWith operator on reactivex.io

Declaration

Swift

func startWith(_ elements: Element ...)
    -> Observable<Element>

Parameters

| elements |

Elements 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, use observeOn.

Seealso

subscribeOn operator on reactivex.io

Declaration

Swift

func subscribe(on scheduler: ImmediateSchedulerType)
    -> Observable<Element>

Parameters

| scheduler |

Scheduler 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, use observeOn.

Seealso

subscribeOn operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "subscribe(on:﹚")
func subscribeOn(_ scheduler: ImmediateSchedulerType)
    -> Observable<Element>

Parameters

| scheduler |

Scheduler 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 + switchLatest operator

Seealso

flatMapLatest operator on reactivex.io

Declaration

Swift

func flatMapLatest<Source: ObservableConvertibleType>(_ selector: @escaping (Element) throws -> Source)
    -> Observable<Source.Element>

Parameters

| selector |

A 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 + switchLatest operator

Seealso

flatMapLatest operator on reactivex.io

Declaration

Swift

func flatMapLatest<Source: InfallibleType>(_ selector: @escaping (Element) throws -> Source)
    -> Infallible<Source.Element>

Parameters

| selector |

A 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 switchTo sequence if the sequence is empty.

Seealso

DefaultIfEmpty operator on reactivex.io

Declaration

Swift

func ifEmpty(switchTo other: Observable<Element>) -> Observable<Element>

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.

`

                take(_:)
                ` Extension method 

Returns a specified number of contiguous elements from the start of an observable sequence.

Seealso

take operator on reactivex.io

Declaration

Swift

func take(_ count: Int)
    -> Observable<Element>

Parameters

| count |

The 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:scheduler:)
                ` Extension method 

Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.

Seealso

take operator on reactivex.io

Declaration

Swift

func take(for duration: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| duration |

Duration for taking elements from the start of the sequence.

| | scheduler |

Scheduler 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(_:scheduler:)
                ` Extension method 

Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.

Seealso

take operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "take(for:scheduler:﹚")
func take(_ duration: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| duration |

Duration for taking elements from the start of the sequence.

| | scheduler |

Scheduler 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.

Seealso

takeLast operator on reactivex.io

Declaration

Swift

func takeLast(_ count: Int)
    -> Observable<Element>

Parameters

| count |

Number 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.

Seealso

takeUntil operator on reactivex.io

Declaration

Swift

func take(until other: some ObservableType)
    -> Observable<Element>

Parameters

| other |

Observable 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:behavior:)
                ` Extension method 

Returns elements from an observable sequence until the specified condition is true.

Seealso

takeUntil operator on reactivex.io

Declaration

Swift

func take(
    until predicate: @escaping (Element) throws -> Bool,
    behavior: TakeBehavior = .exclusive
)
    -> Observable<Element>

Parameters

| predicate |

A function to test each element for a condition.

| | behavior |

Whether 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:behavior:)
                ` Extension method 

Returns elements from an observable sequence as long as a specified condition is true.

Seealso

takeWhile operator on reactivex.io

Declaration

Swift

func take(
    while predicate: @escaping (Element) throws -> Bool,
    behavior: TakeBehavior = .exclusive
)
    -> Observable<Element>

Parameters

| predicate |

A 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.

Seealso

takeUntil operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "take(until:﹚")
func takeUntil(_ other: some ObservableType)
    -> Observable<Element>

Parameters

| other |

Observable 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(_:predicate:)
                ` Extension method 

Returns elements from an observable sequence until the specified condition is true.

Seealso

takeUntil operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "take(until:behavior:﹚")
func takeUntil(
    _ behavior: TakeBehavior,
    predicate: @escaping (Element) throws -> Bool
)
    -> Observable<Element>

Parameters

| behavior |

Whether or not to include the last element matching the predicate.

| | predicate |

A 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.

Seealso

takeWhile operator on reactivex.io

Declaration

Swift

@available(*, deprecated, renamed: "take(while:﹚")
func takeWhile(_ predicate: @escaping (Element) throws -> Bool)
    -> Observable<Element>

Parameters

| predicate |

A 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(_:latest:scheduler:)
                ` Extension method 

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.

Seealso

debounce operator on reactivex.io

Declaration

Swift

func throttle(_ dueTime: RxTimeInterval, latest: Bool = true, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| dueTime |

Throttling duration for each element.

| | latest |

Should latest element received in a dueTime wide time window since last element emission be emitted.

| | scheduler |

Scheduler to run the throttle timers on.

|

Return Value

The throttled sequence.

`

                timeout(_:scheduler:)
                ` Extension method 

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

timeout operator on reactivex.io

Declaration

Swift

func timeout(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| dueTime |

Maximum duration between values before a timeout occurs.

| | scheduler |

Scheduler to run the timeout timer on.

|

Return Value

An observable sequence with a RxError.timeout in case of a timeout.

`

                timeout(_:other:scheduler:)
                ` Extension method 

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

timeout operator on reactivex.io

Declaration

Swift

func timeout<Source: ObservableConvertibleType>(_ dueTime: RxTimeInterval, other: Source, scheduler: SchedulerType)
    -> Observable<Element> where Element == Source.Element

Parameters

| dueTime |

Maximum duration between values before a timeout occurs.

| | other |

Sequence to return in case of a timeout.

| | scheduler |

Scheduler to run the timeout timer on.

|

Return Value

The source sequence switching to the other sequence in case of a timeout.

`

                toArray()
                ` Extension method 

Converts an Observable into a Single that emits the whole sequence as a single array and then terminates.

For aggregation behavior see reduce.

Seealso

toArray operator on reactivex.io

Declaration

Swift

func toArray()
    -> Single<[Element]>

Return Value

A Single sequence containing all the emitted elements as array.

`

                using(_:observableFactory:)
                ` Extension method 

Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence’s lifetime.

Seealso

using operator on reactivex.io

Declaration

Swift

static func using<Resource>(_ resourceFactory: @escaping () throws -> Resource, observableFactory: @escaping (Resource) throws -> Observable<Element>) -> Observable<Element> where Resource : Disposable

Parameters

| resourceFactory |

Factory function to obtain a resource object.

| | observableFactory |

Factory 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:count:scheduler:)
                ` Extension method 

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

window operator on reactivex.io

Declaration

Swift

func window(timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType)
    -> Observable<Observable<Element>>

Parameters

| timeSpan |

Maximum time length of a window.

| | count |

Maximum element count of a window.

| | scheduler |

Scheduler to run windowing timers on.

|

Return Value

An observable sequence of windows (instances of Observable).

`

                withLatestFrom(_:resultSelector:)
                ` Extension method 

Merges two observable sequences into one observable sequence by combining each element from self with the latest element from the second source, if any.

Seealso

combineLatest operator on reactivex.io

Note

Elements emitted by self before the second source has emitted any values will be omitted.

Declaration

Swift

func withLatestFrom<Source, ResultType>(_ second: Source, resultSelector: @escaping (Element, Source.Element) throws -> ResultType) -> Observable<ResultType> where Source : ObservableConvertibleType

Parameters

| second |

Second observable source.

| | resultSelector |

Function 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 self emits an element.

Seealso

combineLatest operator on reactivex.io

Note

Elements emitted by self before the second source has emitted any values will be omitted.

Declaration

Swift

func withLatestFrom<Source>(_ second: Source) -> Observable<Source.Element> where Source : ObservableConvertibleType

Parameters

| second |

Second 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(_:resultSelector:)
                ` 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

func withUnretained<Object: AnyObject, Out>(
    _ obj: Object,
    resultSelector: @escaping (Object, Element) -> Out
) -> Observable<Out>

Parameters

| obj |

The object to provide an unretained reference on.

| | resultSelector |

A function to combine the unretained referenced on obj and the value of the observable sequence.

|

Return Value

An observable sequence that contains the result of resultSelector being called with an unretained reference on obj and 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

func withUnretained<Object>(_ obj: Object) -> Observable<(Object, Element)> where Object : AnyObject

Parameters

| obj |

The object to provide an unretained reference on.

|

Return Value

An observable sequence of tuples that contains both an unretained reference on obj and the values of the original sequence.

`

                zip(_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

static func zip<Collection: Swift.Collection>(_ collection: Collection, resultSelector: @escaping ([Collection.Element.Element]) throws -> Element) -> Observable<Element>
    where Collection.Element: ObservableType

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 whenever all of the observable sequences have produced an element at a corresponding index.

Seealso

zip operator on reactivex.io

Declaration

Swift

static func zip<Collection: Swift.Collection>(_ collection: Collection) -> Observable<[Element]>
    where Collection.Element: ObservableType, Collection.Element.Element == Element

Return Value

An observable sequence containing the result of combining elements of the sources.

`

                zip(_:_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

static func zip<O1: ObservableType, O2: ObservableType>
(_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.Element, O2.Element) throws -> Element)
    -> Observable<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(_:_:_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

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

| 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(_:_:_:_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

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

| 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(_:_:_:_:_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

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

| 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(_:_:_:_:_:_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

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

| 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(_:_:_:_:_:_:_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

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

| 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(_:_:_:_:_:_:_:_:resultSelector:)
                ` Extension method 

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

zip operator on reactivex.io

Declaration

Swift

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

| 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.

`

                asSingle()
                ` Extension method 

The asSingle operator throws a RxError.noElements or RxError.moreThanOneElement if the source Observable does not emit exactly one element before successfully completing.

Seealso

single operator on reactivex.io

Declaration

Swift

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 method 

The first operator emits only the very first item emitted by this Observable, or nil if this Observable completes without emitting anything.

Seealso

single operator on reactivex.io

Declaration

Swift

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 method 

The asMaybe operator throws a RxError.moreThanOneElement if the source Observable does not emit at most one element before successfully completing.

Seealso

single operator on reactivex.io

Declaration

Swift

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.

Available where Element == Any

`

                combineLatest(_:_:)
                ` Extension method 

Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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.

Seealso

combineLatest operator on reactivex.io

Declaration

Swift

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.

Available where Element == Data

`

                decode(type:decoder:)
                ` Extension method 

Attempt to decode the emitted Data using a provided decoder.

Note

If using a custom decoder, it must conform to the DataDecoder protocol.

Declaration

Swift

func decode<Item: Decodable>(
    type: Item.Type,
    decoder: some DataDecoder
) -> Observable<Item>

Parameters

| type |

A Decodable-conforming type to attempt to decode to

| | decoder |

A capable decoder, e.g. JSONDecoder or PropertyListDecoder

|

Return Value

An Observable of the decoded type

Available where Element: EventConvertible

`

                dematerialize()
                ` Extension method 

Convert any previously materialized Observable into it’s original form.

Seealso

materialize operator on reactivex.io

Declaration

Swift

func dematerialize() -> Observable<Element.Element>

Return Value

The dematerialized observable sequence.

Available where Element: Equatable

`

                distinctUntilChanged()
                ` Extension method 

Returns an observable sequence that contains only distinct contiguous elements according to equality operator.

Seealso

distinct operator on reactivex.io

Declaration

Swift

func distinctUntilChanged()
    -> Observable<Element>

Return Value

An observable sequence only containing the distinct contiguous elements, based on equality operator, from the source sequence.

Available where Element: ObservableConvertibleType

`

                merge()
                ` Extension method 

Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.

Seealso

merge operator on reactivex.io

Declaration

Swift

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

merge operator on reactivex.io

Declaration

Swift

func merge(maxConcurrent: Int)
    -> Observable<Element.Element>

Parameters

| maxConcurrent |

Maximum number of inner observable sequences being subscribed to concurrently.

|

Return Value

The observable sequence that merges the elements of the inner sequences.

`

                concat()
                ` Extension method 

Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.

Seealso

concat operator on reactivex.io

Declaration

Swift

func concat() -> Observable<Element.Element>

Return Value

An observable sequence that contains the elements of each observed inner sequence, in sequential order.

Available where Element: RxAbstractInteger

`

                range(start:count:scheduler:)
                ` Extension method 

Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to generate and send out observer messages.

Seealso

range operator on reactivex.io

Declaration

Swift

static func range(start: Element, count: Element, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<Element>

Parameters

| start |

The value of the first integer in the sequence.

| | count |

The number of sequential integers to generate.

| | scheduler |

Scheduler to run the generator loop on.

|

Return Value

An observable sequence that contains a range of sequential integral numbers.

Available where Element: ObservableConvertibleType

`

                switchLatest()
                ` Extension method 

Transforms 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

switch operator on reactivex.io

Declaration

Swift

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.

Available where Element: RxAbstractInteger

`

                interval(_:scheduler:)
                ` Extension method 

Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.

Seealso

interval operator on reactivex.io

Declaration

Swift

static func interval(_ period: RxTimeInterval, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| period |

Period for producing the values in the resulting sequence.

| | scheduler |

Scheduler to run the timer on.

|

Return Value

An observable sequence that produces a value after each period.

`

                timer(_:period:scheduler:)
                ` Extension method 

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

timer operator on reactivex.io

Declaration

Swift

static func timer(_ dueTime: RxTimeInterval, period: RxTimeInterval? = nil, scheduler: SchedulerType)
    -> Observable<Element>

Parameters

| dueTime |

Relative time at which to produce the first value.

| | period |

Period to produce subsequent values.

| | scheduler |

Scheduler to run timers on.

|

Return Value

An observable sequence that produces a value after due time has elapsed and then each period.

Available where Element == Any

`

                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

zip operator on reactivex.io

Declaration

Swift

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

zip operator on reactivex.io

Declaration

Swift

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

zip operator on reactivex.io

Declaration

Swift

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

zip operator on reactivex.io

Declaration

Swift

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

zip operator on reactivex.io

Declaration

Swift

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

zip operator on reactivex.io

Declaration

Swift

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

zip operator on reactivex.io

Declaration

Swift

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.

Available where Element == Never

`

                asCompletable()
                ` Extension method 

Declaration

Swift

func asCompletable()
    -> Completable

Return Value

An observable sequence that completes.