Observable

public class Observable<Element> : ObservableType

A type-erased ObservableType.

It represents a push style sequence.

  • E

    Type of elements in sequence.

    Declaration

    Swift

    public typealias E = Element
  • Undocumented

    Declaration

    Swift

    public class Observable<Element> : ObservableType
  • Undocumented

    Declaration

    Swift

    public class Observable<Element> : ObservableType
  • Creates an observable sequence from a specified subscribe method implementation.

    Declaration

    Swift

    public static func create(subscribe: (AnyObserver<E>) -> Disposable) -> Observable<E>

    Parameters

    subscribe

    Implementation of the resulting observable sequence’s subscribe method.

    Return Value

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

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

    Declaration

    Swift

    public static func empty() -> Observable<E>

    Return Value

    An observable sequence with no elements.

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

    Declaration

    Swift

    public static func never() -> Observable<E>

    Return Value

    An observable sequence whose observers will never get called.

  • Returns an observable sequence that contains a single element.

    Declaration

    Swift

    public static func just(element: E) -> Observable<E>

    Parameters

    element

    Single element in the resulting observable sequence.

    Return Value

    An observable sequence containing the single specified element.

  • Returns an observable sequence that contains a single element.

    Declaration

    Swift

    public static func just(element: E, scheduler: ImmediateSchedulerType) -> Observable<E>

    Parameters

    element

    Single element in the resulting observable sequence.

    Return Value

    An observable sequence containing the single specified element.

  • Returns an observable sequence that terminates with an error.

    Declaration

    Swift

    public static func error(error: ErrorType) -> Observable<E>

    Return Value

    The observable sequence that terminates with specified error.

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

    Declaration

    Swift

    public static func of(elements: E ..., scheduler: ImmediateSchedulerType? = nil) -> Observable<E>

    Parameters

    elements

    Elements to generate.

    scheduler

    Scheduler to send elements on. If nil, elements are sent immediatelly on subscription.

    Return Value

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

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

    Declaration

    Swift

    public static func deferred(observableFactory: () throws -> Observable<E>)
            -> Observable<E>

    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.

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

    Declaration

    Swift

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

    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.

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

    Declaration

    Swift

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

    Parameters

    element

    Element to repeat.

    scheduler

    Scheduler to run the producer loop on.

    Return Value

    An observable sequence that repeats the given element infinitely.

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

    Declaration

    Swift

    public static func using<R: Disposable>(resourceFactory: () throws -> R, observableFactory: R throws -> Observable<E>) -> Observable<E>

    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.

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

    Declaration

    Swift

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

    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.

  • 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<O1: ObservableType, O2: ObservableType>
            (source1: O1, _ source2: O2, resultSelector: (O1.E, O2.E) throws -> E)
            -> Observable<E>

    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.

  • 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<O1: ObservableType, O2: ObservableType, O3: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, resultSelector: (O1.E, O2.E, O3.E) throws -> E)
            -> Observable<E>

    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.

  • 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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: (O1.E, O2.E, O3.E, O4.E) throws -> E)
            -> Observable<E>

    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.

  • 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<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E)
            -> Observable<E>

    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.

  • 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<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: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E)
            -> Observable<E>

    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.

  • 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<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: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E)
            -> Observable<E>

    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.

  • 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<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: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E)
            -> Observable<E>

    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.

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

    Declaration

    Swift

    public static func interval(period: RxTimeInterval, scheduler: SchedulerType)
            -> Observable<E>

    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.

  • 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, period: RxTimeInterval? = nil, scheduler: SchedulerType)
            -> Observable<E>

    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.

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

    Declaration

    Swift

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

    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.

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

    Declaration

    Swift

    public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, resultSelector: (O1.E, O2.E, O3.E) throws -> E)
                -> Observable<E>

    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.

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

    Declaration

    Swift

    public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: (O1.E, O2.E, O3.E, O4.E) throws -> E)
                -> Observable<E>

    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.

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

    Declaration

    Swift

    public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E)
                -> Observable<E>

    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.

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

    Declaration

    Swift

    public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E)
                -> Observable<E>

    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.

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

    Declaration

    Swift

    public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E)
                -> Observable<E>

    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.

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

    Declaration

    Swift

    public static func combineLatest<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType, O8: ObservableType>
            (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E)
                -> Observable<E>

    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.