PrimitiveSequenceType

public protocol PrimitiveSequenceType

Observable sequences containing 0 or 1 element

  • andThen(_:) Extension method

    Concatenates the second observable sequence to self upon successful termination of self.

    Declaration

    Swift

    public func andThen<E>(_ second: Single<E>) -> Single<E>

    Parameters

    second

    Second observable sequence.

    Return Value

    An observable sequence that contains the elements of self, followed by those of the second sequence.

  • andThen(_:) Extension method

    Concatenates the second observable sequence to self upon successful termination of self.

    Declaration

    Swift

    public func andThen<E>(_ second: Maybe<E>) -> Maybe<E>

    Parameters

    second

    Second observable sequence.

    Return Value

    An observable sequence that contains the elements of self, followed by those of the second sequence.

  • andThen(_:) Extension method

    Concatenates the second observable sequence to self upon successful termination of self.

    Declaration

    Swift

    public func andThen(_ second: Completable) -> Completable

    Parameters

    second

    Second observable sequence.

    Return Value

    An observable sequence that contains the elements of self, followed by those of the second sequence.

  • andThen(_:) Extension method

    Concatenates the second observable sequence to self upon successful termination of self.

    Declaration

    Swift

    public func andThen<E>(_ second: Observable<E>) -> Observable<E>

    Parameters

    second

    Second observable sequence.

    Return Value

    An observable sequence that contains the elements of self, followed by those of the second sequence.

  • CompletableObserver Extension method

    Undocumented

    Declaration

    Swift

    public typealias CompletableObserver = (CompletableEvent) -> Void
  • create(subscribe:) Extension method

    Creates an observable sequence from a specified subscribe method implementation.

    Declaration

    Swift

    public static func create(subscribe: @escaping (@escaping CompletableObserver) -> Disposable) -> PrimitiveSequence<TraitType, ElementType>

    Parameters

    subscribe

    Implementation of the resulting observable sequence’s subscribe method.

    Return Value

    The observable sequence with the specified implementation for the subscribe method.

  • subscribe(_:) Extension method

    Subscribes observer to receive events for this sequence.

    Declaration

    Swift

    public func subscribe(_ observer: @escaping (CompletableEvent) -> Void) -> Disposable

    Return Value

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

  • Subscribes a completion handler and an error handler for this sequence.

    Declaration

    Swift

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

    Parameters

    onCompleted

    Action to invoke upon graceful termination of the observable sequence.

    onError

    Action to invoke upon errored termination of the observable sequence.

    Return Value

    Subscription object used to unsubscribe from the observable sequence.

  • error(_:) Extension method

    Returns an observable sequence that terminates with an error.

    Declaration

    Swift

    public static func error(_ error: Swift.Error) -> Completable

    Return Value

    The observable sequence that terminates with specified error.

  • never() Extension method

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

    Declaration

    Swift

    public static func never() -> Completable

    Return Value

    An observable sequence whose observers will never get called.

  • empty() Extension method

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

    Declaration

    Swift

    public static func empty() -> Completable

    Return Value

    An observable sequence with no elements.

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

    Declaration

    Swift

    public func `do`(onError: ((Swift.Error) throws -> Void)? = nil,
                     onCompleted: (() throws -> Void)? = nil,
                     onSubscribe: (() -> Void)? = nil,
                     onSubscribed: (() -> Void)? = nil,
                     onDispose: (() -> Void)? = nil)
        -> Completable

    Parameters

    onNext

    Action to invoke for each element in the observable sequence.

    onError

    Action to invoke upon errored termination of the observable sequence.

    onCompleted

    Action to invoke upon graceful termination of the observable sequence.

    onSubscribe

    Action to invoke before subscribing to source observable sequence.

    onSubscribed

    Action to invoke after subscribing to source observable sequence.

    onDispose

    Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.

    Return Value

    The source sequence with the side-effecting behavior applied.

  • concat(_:) Extension method

    Concatenates the second observable sequence to self upon successful termination of self.

    Declaration

    Swift

    public func concat(_ second: Completable) -> Completable

    Parameters

    second

    Second observable sequence.

    Return Value

    An observable sequence that contains the elements of self, followed by those of the second sequence.

  • concat(_:) Extension method

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

    Declaration

    Swift

    public static func concat<S: Sequence>(_ sequence: S) -> Completable
        where S.Iterator.Element == Completable

    Return Value

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

  • concat(_:) Extension method

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

    Declaration

    Swift

    public static func concat<C: Collection>(_ collection: C) -> Completable
        where C.Iterator.Element == Completable

    Return Value

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

  • concat(_:) Extension method

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

    Declaration

    Swift

    public static func concat(_ sources: Completable...) -> Completable

    Return Value

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

  • merge(_:) Extension method

    Merges elements from all observable sequences from collection into a single observable sequence.

    Declaration

    Swift

    public static func merge<C: Collection>(_ sources: C) -> Completable
        where C.Iterator.Element == Completable

    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.

    Declaration

    Swift

    public static func merge(_ sources: [Completable]) -> Completable

    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.

    Declaration

    Swift

    public static func merge(_ sources: Completable...) -> Completable

    Parameters

    sources

    Collection of observable sequences to merge.

    Return Value

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

  • MaybeObserver Extension method

    Undocumented

    Declaration

    Swift

    public typealias MaybeObserver = (MaybeEvent<ElementType>) -> Void
  • create(subscribe:) Extension method

    Creates an observable sequence from a specified subscribe method implementation.

    Declaration

    Swift

    public static func create(subscribe: @escaping (@escaping MaybeObserver) -> Disposable) -> PrimitiveSequence<TraitType, ElementType>

    Parameters

    subscribe

    Implementation of the resulting observable sequence’s subscribe method.

    Return Value

    The observable sequence with the specified implementation for the subscribe method.

  • subscribe(_:) Extension method

    Subscribes observer to receive events for this sequence.

    Declaration

    Swift

    public func subscribe(_ observer: @escaping (MaybeEvent<ElementType>) -> Void) -> Disposable

    Return Value

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

  • Subscribes a success handler, an error handler, and a completion handler for this sequence.

    Declaration

    Swift

    public func subscribe(onSuccess: ((ElementType) -> Void)? = nil,
                          onError: ((Swift.Error) -> Void)? = nil,
                          onCompleted: (() -> Void)? = nil) -> Disposable

    Parameters

    onSuccess

    Action to invoke for each element in the observable sequence.

    onError

    Action to invoke upon errored termination of the observable sequence.

    onCompleted

    Action to invoke upon graceful termination of the observable sequence.

    Return Value

    Subscription object used to unsubscribe from the observable sequence.

  • just(_:) Extension method

    Returns an observable sequence that contains a single element.

    Declaration

    Swift

    public static func just(_ element: ElementType) -> Maybe<ElementType>

    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.

    Declaration

    Swift

    public static func just(_ element: ElementType, scheduler: ImmediateSchedulerType) -> Maybe<ElementType>

    Parameters

    element

    Single element in the resulting observable sequence.

    scheduler

    Scheduler to send the single element on.

    Return Value

    An observable sequence containing the single specified element.

  • error(_:) Extension method

    Returns an observable sequence that terminates with an error.

    Declaration

    Swift

    public static func error(_ error: Swift.Error) -> Maybe<ElementType>

    Return Value

    The observable sequence that terminates with specified error.

  • never() Extension method

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

    Declaration

    Swift

    public static func never() -> Maybe<ElementType>

    Return Value

    An observable sequence whose observers will never get called.

  • empty() Extension method

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

    Declaration

    Swift

    public static func empty() -> Maybe<ElementType>

    Return Value

    An observable sequence with no elements.

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

    Declaration

    Swift

    public func `do`(onNext: ((ElementType) throws -> Void)? = nil,
                     onError: ((Swift.Error) throws -> Void)? = nil,
                     onCompleted: (() throws -> Void)? = nil,
                     onSubscribe: (() -> Void)? = nil,
                     onSubscribed: (() -> Void)? = nil,
                     onDispose: (() -> Void)? = nil)
        -> Maybe<ElementType>

    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.

    onSubscribe

    Action to invoke before subscribing to source observable sequence.

    onSubscribed

    Action to invoke after subscribing to source observable sequence.

    onDispose

    Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.

    Return Value

    The source sequence with the side-effecting behavior applied.

  • filter(_:) Extension method

    Filters the elements of an observable sequence based on a predicate.

    Declaration

    Swift

    public func filter(_ predicate: @escaping (ElementType) throws -> Bool)
        -> Maybe<ElementType>

    Parameters

    predicate

    A function to test each source element for a condition.

    Return Value

    An observable sequence that contains elements from the input sequence that satisfy the condition.

  • map(_:) Extension method

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

    Declaration

    Swift

    public func map<R>(_ transform: @escaping (ElementType) throws -> R)
        -> Maybe<R>

    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.

  • flatMap(_:) Extension method

    Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.

    Declaration

    Swift

    public func flatMap<R>(_ selector: @escaping (ElementType) throws -> Maybe<R>)
        -> Maybe<R>

    Parameters

    selector

    A transform function to apply to each element.

    Return Value

    An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

  • ifEmpty(default:) Extension method

    Emits elements from the source observable sequence, or a default element if the source observable sequence is empty.

    Declaration

    Swift

    public func ifEmpty(default: ElementType) -> Single<ElementType>

    Parameters

    default

    Default element to be sent if the source does not emit any elements

    Return Value

    An observable sequence which emits default element end completes in case the original sequence is empty

  • ifEmpty(switchTo:) Extension method

    Returns the elements of the specified sequence or switchTo sequence if the sequence is empty.

    Declaration

    Swift

    public func ifEmpty(switchTo other: Maybe<ElementType>) -> Maybe<ElementType>

    Parameters

    switchTo

    Observable sequence being returned when source sequence is empty.

    Return Value

    Observable sequence that contains elements from switchTo sequence if source is empty, otherwise returns source sequence elements.

  • ifEmpty(switchTo:) Extension method

    Returns the elements of the specified sequence or switchTo sequence if the sequence is empty.

    Declaration

    Swift

    public func ifEmpty(switchTo other: Single<ElementType>) -> Single<ElementType>

    Parameters

    switchTo

    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.

  • catchErrorJustReturn(_:) Extension method

    Continues an observable sequence that is terminated by an error with a single element.

    Declaration

    Swift

    public func catchErrorJustReturn(_ element: ElementType)
        -> PrimitiveSequence<TraitType, ElementType>

    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.

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

    Declaration

    Swift

    public static func zip<E1, E2>(_ source1: PrimitiveSequence<TraitType, E1>, _ source2: PrimitiveSequence<TraitType, E2>, resultSelector: @escaping (E1, E2) throws -> ElementType)
        -> PrimitiveSequence<TraitType, ElementType>

    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.

    Declaration

    Swift

    public static func zip<E1, E2>(_ source1: PrimitiveSequence<TraitType, E1>, _ source2: PrimitiveSequence<TraitType, E2>, resultSelector: @escaping (E1, E2) throws -> ElementType)
        -> PrimitiveSequence<TraitType, ElementType>

    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.

  • timer(_: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.

    Declaration

    Swift

    public static func timer(_ dueTime: RxTimeInterval, scheduler: SchedulerType)
        -> PrimitiveSequence<TraitType, ElementType>

    Parameters

    dueTime

    Relative time at which to produce the first value.

    scheduler

    Scheduler to run timers on.

    Return Value

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

  • SingleObserver Extension method

    Undocumented

    Declaration

    Swift

    public typealias SingleObserver = (SingleEvent<ElementType>) -> Void
  • create(subscribe:) Extension method

    Creates an observable sequence from a specified subscribe method implementation.

    Declaration

    Swift

    public static func create(subscribe: @escaping (@escaping SingleObserver) -> Disposable) -> Single<ElementType>

    Parameters

    subscribe

    Implementation of the resulting observable sequence’s subscribe method.

    Return Value

    The observable sequence with the specified implementation for the subscribe method.

  • subscribe(_:) Extension method

    Subscribes observer to receive events for this sequence.

    Declaration

    Swift

    public func subscribe(_ observer: @escaping (SingleEvent<ElementType>) -> Void) -> Disposable

    Return Value

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

  • Subscribes a success handler, and an error handler for this sequence.

    Declaration

    Swift

    public func subscribe(onSuccess: ((ElementType) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil) -> Disposable

    Parameters

    onSuccess

    Action to invoke for each element in the observable sequence.

    onError

    Action to invoke upon errored termination of the observable sequence.

    Return Value

    Subscription object used to unsubscribe from the observable sequence.

  • just(_:) Extension method

    Returns an observable sequence that contains a single element.

    Declaration

    Swift

    public static func just(_ element: ElementType) -> Single<ElementType>

    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.

    Declaration

    Swift

    public static func just(_ element: ElementType, scheduler: ImmediateSchedulerType) -> Single<ElementType>

    Parameters

    element

    Single element in the resulting observable sequence.

    scheduler

    Scheduler to send the single element on.

    Return Value

    An observable sequence containing the single specified element.

  • error(_:) Extension method

    Returns an observable sequence that terminates with an error.

    Declaration

    Swift

    public static func error(_ error: Swift.Error) -> Single<ElementType>

    Return Value

    The observable sequence that terminates with specified error.

  • never() Extension method

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

    Declaration

    Swift

    public static func never() -> Single<ElementType>

    Return Value

    An observable sequence whose observers will never get called.

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

    Declaration

    Swift

    public func `do`(onSuccess: ((ElementType) throws -> Void)? = nil,
                     onError: ((Swift.Error) throws -> Void)? = nil,
                     onSubscribe: (() -> Void)? = nil,
                     onSubscribed: (() -> Void)? = nil,
                     onDispose: (() -> Void)? = nil)
        -> Single<ElementType>

    Parameters

    onSuccess

    Action to invoke for each element in the observable sequence.

    onError

    Action to invoke upon errored termination of the observable sequence.

    onSubscribe

    Action to invoke before subscribing to source observable sequence.

    onSubscribed

    Action to invoke after subscribing to source observable sequence.

    onDispose

    Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.

    Return Value

    The source sequence with the side-effecting behavior applied.

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

    Declaration

    Swift

    @available(*, deprecated, renamed: "do(onSuccess:onError:onSubscribe:onSubscribed:onDispose:﹚")
    public func `do`(onNext: ((ElementType) throws -> Void)?,
                     onError: ((Swift.Error) throws -> Void)? = nil,
                     onSubscribe: (() -> Void)? = nil,
                     onSubscribed: (() -> Void)? = nil,
                     onDispose: (() -> Void)? = nil)
        -> Single<ElementType>

    Parameters

    onNext

    Action to invoke for each element in the observable sequence.

    onError

    Action to invoke upon errored termination of the observable sequence.

    onSubscribe

    Action to invoke before subscribing to source observable sequence.

    onSubscribed

    Action to invoke after subscribing to source observable sequence.

    onDispose

    Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed.

    Return Value

    The source sequence with the side-effecting behavior applied.

  • filter(_:) Extension method

    Filters the elements of an observable sequence based on a predicate.

    Declaration

    Swift

    public func filter(_ predicate: @escaping (ElementType) throws -> Bool)
        -> Maybe<ElementType>

    Parameters

    predicate

    A function to test each source element for a condition.

    Return Value

    An observable sequence that contains elements from the input sequence that satisfy the condition.

  • map(_:) Extension method

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

    Declaration

    Swift

    public func map<R>(_ transform: @escaping (ElementType) throws -> R)
        -> Single<R>

    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.

  • flatMap(_:) Extension method

    Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.

    Declaration

    Swift

    public func flatMap<R>(_ selector: @escaping (ElementType) throws -> Single<R>)
        -> Single<R>

    Parameters

    selector

    A transform function to apply to each element.

    Return Value

    An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

  • flatMapMaybe(_:) Extension method

    Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.

    Declaration

    Swift

    public func flatMapMaybe<R>(_ selector: @escaping (ElementType) throws -> Maybe<R>)
        -> Maybe<R>

    Parameters

    selector

    A transform function to apply to each element.

    Return Value

    An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

  • flatMapCompletable(_:) Extension method

    Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.

    Declaration

    Swift

    public func flatMapCompletable(_ selector: @escaping (ElementType) throws -> Completable)
        -> Completable

    Parameters

    selector

    A transform function to apply to each element.

    Return Value

    An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

  • zip(_:_:) Extension 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.

    Declaration

    Swift

    public static func zip<C: Collection, R>(_ collection: C, _ resultSelector: @escaping ([ElementType]) throws -> R) -> PrimitiveSequence<TraitType, R> where C.Iterator.Element == PrimitiveSequence<TraitType, ElementType>

    Parameters

    resultSelector

    Function to invoke for each series of elements at corresponding indexes in the sources.

    Return Value

    An observable sequence containing the result of combining elements of the sources using the specified result selector function.

  • zip(_:) Extension method

    Merges the specified observable sequences into one observable sequence all of the observable sequences have produced an element at a corresponding index.

    Declaration

    Swift

    public static func zip<C>(_ collection: C) -> PrimitiveSequence<TraitType, [ElementType]> where C : Collection, C.Element == PrimitiveSequence<SingleTrait, Self.ElementType>

    Return Value

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

  • catchErrorJustReturn(_:) Extension method

    Continues an observable sequence that is terminated by an error with a single element.

    Declaration

    Swift

    public func catchErrorJustReturn(_ element: ElementType)
        -> PrimitiveSequence<TraitType, ElementType>

    Parameters

    element

    Last element in an observable sequence in case error occurs.

    Return Value

    An observable sequence containing the source sequence’s elements, followed by the element in case an error occurred.

  • asMaybe() Extension method

    Converts self to Maybe trait.

    Declaration

    Swift

    public func asMaybe() -> Maybe<ElementType>

    Return Value

    Maybe trait that represents self.

  • asCompletable() Extension method

    Converts self to Completable trait.

    Declaration

    Swift

    public func asCompletable() -> Completable

    Return Value

    Completable trait that represents self.