Observable
public class Observable<Element> : ObservableType
A type-erased ObservableType.
It represents a push style sequence.
-
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.
Seealso
Declaration
Swift
public static func create(subscribe: (AnyObserver<E>) -> Disposable) -> Observable<E>Parameters
subscribeImplementation of the resulting observable sequence’s
subscribemethod.Return Value
The observable sequence with the specified implementation for the
subscribemethod.
-
Returns an empty observable sequence, using the specified scheduler to send out the single
Completedmessage.Seealso
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.
Seealso
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.
Seealso
Declaration
Swift
public static func just(element: E) -> Observable<E>Parameters
elementSingle 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.
Seealso
Declaration
Swift
public static func just(element: E, scheduler: ImmediateSchedulerType) -> Observable<E>Parameters
elementSingle 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.Seealso
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.
Seealso
Declaration
Swift
public static func of(elements: E ..., scheduler: ImmediateSchedulerType? = nil) -> Observable<E>Parameters
elementsElements to generate.
schedulerScheduler 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.
Seealso
Declaration
Swift
public static func deferred(observableFactory: () throws -> Observable<E>) -> Observable<E>Parameters
observableFactoryObservable factory function to invoke for each observer that subscribes to the resulting sequence.
Return Value
An observable sequence whose observers trigger an invocation of the given observable factory function.
-
Generates an observable sequence by running a state-driven loop producing the sequence’s elements, using the specified scheduler to run the loop send out observer messages.
Seealso
Declaration
Swift
public static func generate(initialState initialState: E, condition: E throws -> Bool, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance, iterate: E throws -> E) -> Observable<E>Parameters
initialStateInitial state.
conditionCondition to terminate generation (upon returning
false).iterateIteration step function.
schedulerScheduler on which to run the generator loop.
Return Value
The generated sequence.
-
Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
Seealso
Declaration
Swift
public static func repeatElement(element: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<E>Parameters
elementElement to repeat.
schedulerScheduler 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.
Seealso
Declaration
Swift
public static func using<R: Disposable>(resourceFactory: () throws -> R, observableFactory: R throws -> Observable<E>) -> Observable<E>Parameters
resourceFactoryFactory function to obtain a resource object.
observableFactoryFactory function to obtain an observable sequence that depends on the obtained resource.
Return Value
An observable sequence whose lifetime controls the lifetime of the dependent resource object.
-
Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to generate and send out observer messages.
Seealso
Declaration
Swift
public static func range(start start: E, count: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable<E>Parameters
startThe value of the first integer in the sequence.
countThe number of sequential integers to generate.
schedulerScheduler to run the generator loop on.
Return Value
An observable sequence that contains a range of sequential integral numbers.
-
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<O1: ObservableType, O2: ObservableType> (source1: O1, _ source2: O2, resultSelector: (O1.E, O2.E) throws -> E) -> Observable<E>Parameters
resultSelectorFunction to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<O1: ObservableType, O2: ObservableType, O3: ObservableType> (source1: O1, _ source2: O2, _ source3: O3, resultSelector: (O1.E, O2.E, O3.E) throws -> E) -> Observable<E>Parameters
resultSelectorFunction to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType> (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: (O1.E, O2.E, O3.E, O4.E) throws -> E) -> Observable<E>Parameters
resultSelectorFunction to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType> (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E) -> Observable<E>Parameters
resultSelectorFunction to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType> (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E) -> Observable<E>Parameters
resultSelectorFunction to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType> (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E) -> Observable<E>Parameters
resultSelectorFunction to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<O1: ObservableType, O2: ObservableType, O3: ObservableType, O4: ObservableType, O5: ObservableType, O6: ObservableType, O7: ObservableType, O8: ObservableType> (source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E) -> Observable<E>Parameters
resultSelectorFunction to invoke for each series of elements at corresponding indexes in the sources.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
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
periodPeriod for producing the values in the resulting sequence.
schedulerScheduler to run the timer on.
Return Value
An observable sequence that produces a value after each period.
-
Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed, using the specified scheduler to run timers.
Seealso
Declaration
Swift
public static func timer(dueTime: RxTimeInterval, period: RxTimeInterval? = nil, scheduler: SchedulerType) -> Observable<E>Parameters
dueTimeRelative time at which to produce the first value.
periodPeriod to produce subsequent values.
schedulerScheduler to run timers on.
Return Value
An observable sequence that produces a value after due time has elapsed and then each period.
-
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
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
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
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
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
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
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
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
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
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
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
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
-
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
resultSelectorFunction to invoke whenever any of the sources produces an element.
Return Value
An observable sequence containing the result of combining elements of the sources using the specified result selector function.
Observable Class Reference