InfallibleType
public protocol InfallibleType : ObservableConvertibleType
Infallible
is an Observable
-like push-style interface
which is guaranteed to not emit error events.
Unlike SharedSequence
, it does not share its resources or
replay its events, but acts as a standard Observable
.
-
combineLatest(_:
Extension methodresultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<Collection: Swift.Collection>(_ collection: Collection, resultSelector: @escaping ([Collection.Element.Element]) throws -> Element) -> Infallible<Element> where Collection.Element: InfallibleType
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.
Declaration
Swift
public static func combineLatest<Collection: Swift.Collection>(_ collection: Collection) -> Infallible<[Element]> where Collection.Element: InfallibleType, Collection.Element.Element == Element
Return Value
An observable sequence containing the result of combining elements of the sources.
-
values
Extension methodAllows iterating over the values of an Infallible asynchronously via Swift’s concurrency features (
async/await
)A sample usage would look like so:
for await value in observable.values { // Handle emitted values }
Declaration
Swift
var values: AsyncStream<Element> { get }
-
just(_:
Extension method) Returns an infallible sequence that contains a single element.
Seealso
Declaration
Swift
public static func just(_ element: Element) -> Infallible<Element>
Parameters
element
Single element in the resulting infallible sequence.
Return Value
An infallible sequence containing the single specified element.
-
just(_:
Extension methodscheduler: ) Returns an infallible sequence that contains a single element.
Seealso
Declaration
Swift
public static func just(_ element: Element, scheduler: ImmediateSchedulerType) -> Infallible<Element>
Parameters
element
Single element in the resulting infallible sequence.
scheduler
Scheduler to send the single element on.
Return Value
An infallible sequence containing the single specified element.
-
never()
Extension methodReturns a non-terminating infallible sequence, which can be used to denote an infinite duration.
Seealso
Declaration
Swift
public static func never() -> Infallible<Element>
Return Value
An infallible sequence whose observers will never get called.
-
empty()
Extension methodReturns an empty infallible sequence, using the specified scheduler to send out the single
Completed
message.Seealso
Declaration
Swift
public static func empty() -> Infallible<Element>
Return Value
An infallible sequence with no elements.
-
deferred(_:
Extension method) Returns an infallible sequence that invokes the specified factory function whenever a new observer subscribes.
Seealso
Declaration
Swift
public static func deferred(_ observableFactory: @escaping () throws -> Infallible<Element>) -> Infallible<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.
-
filter(_:
Extension method) Filters the elements of an observable sequence based on a predicate.
Seealso
Declaration
Swift
public func filter(_ predicate: @escaping (Element) -> Bool) -> Infallible<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.
-
map(_:
Extension method) Projects each element of an observable sequence into a new form.
Seealso
Declaration
Swift
public func map<Result>(_ transform: @escaping (Element) -> Result) -> Infallible<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.
-
compactMap(_:
Extension method) Projects each element of an observable sequence into an optional form and filters all optional results.
Declaration
Swift
public func compactMap<Result>(_ transform: @escaping (Element) -> Result?) -> Infallible<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.
-
distinctUntilChanged(_:
Extension method) Returns an observable sequence that contains only distinct contiguous elements according to the
keySelector
.Declaration
Swift
public func distinctUntilChanged<Key: Equatable>(_ keySelector: @escaping (Element) throws -> Key) -> Infallible<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
.Declaration
Swift
public func distinctUntilChanged(_ comparer: @escaping (Element, Element) throws -> Bool) -> Infallible<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(_:
Extension methodcomparer: ) Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
Declaration
Swift
public func distinctUntilChanged<K>(_ keySelector: @escaping (Element) throws -> K, comparer: @escaping (K, K) throws -> Bool) -> Infallible<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.
Declaration
Swift
public func distinctUntilChanged<Property: Equatable>(at keyPath: KeyPath<Element, Property>) -> Infallible<Element>
Return Value
An observable sequence only containing the distinct contiguous elements, based on equality operator on the provided key path
-
debounce(_:
Extension methodscheduler: ) Ignores elements from an observable sequence which are followed by another element within a specified relative time duration, using the specified scheduler to run throttling timers.
Declaration
Swift
public func debounce(_ dueTime: RxTimeInterval, scheduler: SchedulerType) -> Infallible<Element>
Parameters
dueTime
Throttling duration for each element.
scheduler
Scheduler to run the throttle timers on.
Return Value
The throttled sequence.
-
throttle(_:
Extension methodlatest: scheduler: ) Returns an Observable that emits the first and the latest item emitted by the source Observable during sequential time windows of a specified duration.
This operator makes sure that no two elements are emitted in less then dueTime.
Declaration
Swift
public func throttle(_ dueTime: RxTimeInterval, latest: Bool = true, scheduler: SchedulerType) -> Infallible<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.
-
flatMap(_:
Extension method) Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
Seealso
Declaration
Swift
public func flatMap<Source: ObservableConvertibleType>(_ selector: @escaping (Element) -> 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 one-to-many transform function on each element of the input sequence.
-
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
operatorDeclaration
Swift
public func flatMapLatest<Source: ObservableConvertibleType>(_ selector: @escaping (Element) -> 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.
-
flatMapFirst(_:
Extension method) Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. If element is received while there is some projected observable sequence being merged it will simply be ignored.
Declaration
Swift
public func flatMapFirst<Source: ObservableConvertibleType>(_ selector: @escaping (Element) -> Source) -> Infallible<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.
-
concat(_:
Extension method) Concatenates the second observable sequence to
self
upon successful termination ofself
.Seealso
Declaration
Swift
public func concat<Source>(_ second: Source) -> Infallible<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
Declaration
Swift
public static func concat<Sequence: Swift.Sequence>(_ sequence: Sequence) -> Infallible<Element> where Sequence.Element == Infallible<Element>
Return Value
An observable sequence that contains the elements of each given sequence, in sequential order.
-
concat(_:
Extension method) Concatenates all observable sequences in the given collection, as long as the previous observable sequence terminated successfully.
This operator has tail recursive optimizations that will prevent stack overflow.
Optimizations will be performed in cases equivalent to following:
[1, [2, [3, …..].concat()].concat].concat()
Seealso
Declaration
Swift
public static func concat<Collection: Swift.Collection>(_ collection: Collection) -> Infallible<Element> where Collection.Element == Infallible<Element>
Return Value
An observable sequence that contains the elements of each given sequence, in sequential order.
-
concat(_:
Extension method) Concatenates all observable sequences in the given collection, as long as the previous observable sequence terminated successfully.
This operator has tail recursive optimizations that will prevent stack overflow.
Optimizations will be performed in cases equivalent to following:
[1, [2, [3, …..].concat()].concat].concat()
Seealso
Declaration
Swift
public static func concat(_ sources: Infallible<Element>...) -> Infallible<Element>
Return Value
An observable sequence that contains the elements of each given sequence, in sequential order.
-
concatMap(_:
Extension method) Projects each element of an observable sequence to an observable sequence and concatenates the resulting observable sequences into one observable sequence.
Seealso
Declaration
Swift
public func concatMap<Source: ObservableConvertibleType>(_ selector: @escaping (Element) -> Source) -> Infallible<Source.Element>
Return Value
An observable sequence that contains the elements of each observed inner sequence, in sequential order.
-
merge(_:
Extension method) Merges elements from all observable sequences from collection into a single observable sequence.
Seealso
Declaration
Swift
public static func merge<Collection>(_ sources: Collection) -> Infallible<Element> where Collection : Collection, Collection.Element == Infallible<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 infallible sequences from array into a single infallible sequence.
Seealso
Declaration
Swift
public static func merge(_ sources: [Infallible<Element>]) -> Infallible<Element>
Parameters
sources
Array of infallible sequences to merge.
Return Value
The infallible sequence that merges the elements of the infallible sequences.
-
merge(_:
Extension method) Merges elements from all infallible sequences into a single infallible sequence.
Seealso
Declaration
Swift
public static func merge(_ sources: Infallible<Element>...) -> Infallible<Element>
Parameters
sources
Collection of infallible sequences to merge.
Return Value
The infallible sequence that merges the elements of the infallible sequences.
-
scan(into:
Extension methodaccumulator: ) Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
For aggregation behavior with no intermediate results, see
reduce
.Seealso
Declaration
Swift
public func scan<Seed>(into seed: Seed, accumulator: @escaping (inout Seed, Element) -> Void) -> Infallible<Seed>
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(_:
Extension methodaccumulator: ) Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
For aggregation behavior with no intermediate results, see
reduce
.Seealso
Declaration
Swift
public func scan<Seed>(_ seed: Seed, accumulator: @escaping (Seed, Element) -> Seed) -> Infallible<Seed>
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.
-
startWith(_:
Extension method) Prepends a value to an observable sequence.
Declaration
Swift
public func startWith(_ element: Element) -> Infallible<Element>
Parameters
element
Element to prepend to the specified sequence.
Return Value
The source sequence prepended with the specified values.
-
take(until:
Extension method) Returns the elements from the source observable sequence until the other observable sequence produces an element.
Declaration
Swift
public func take<Source: InfallibleType>(until other: Source) -> Infallible<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:
Extension method) Returns the elements from the source observable sequence until the other observable sequence produces an element.
Declaration
Swift
public func take<Source: ObservableType>(until other: Source) -> Infallible<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:
Extension methodbehavior: ) Returns elements from an observable sequence until the specified condition is true.
Declaration
Swift
public func take(until predicate: @escaping (Element) throws -> Bool, behavior: TakeBehavior = .exclusive) -> Infallible<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:
Extension methodbehavior: ) Returns elements from an observable sequence as long as a specified condition is true.
Declaration
Swift
public func take(while predicate: @escaping (Element) throws -> Bool, behavior: TakeBehavior = .exclusive) -> Infallible<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.
-
take(_:
Extension method) Returns a specified number of contiguous elements from the start of an observable sequence.
Seealso
Declaration
Swift
public func take(_ count: Int) -> Infallible<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:
Extension methodscheduler: ) Takes elements for the specified duration from the start of the infallible source sequence, using the specified scheduler to run timers.
Seealso
Declaration
Swift
public func take(for duration: RxTimeInterval, scheduler: SchedulerType) -> Infallible<Element>
Parameters
duration
Duration for taking elements from the start of the sequence.
scheduler
Scheduler to run the timer on.
Return Value
An infallible sequence with the elements taken during the specified duration from the start of the source sequence.
-
skip(while:
Extension method) Bypasses elements in an infallible sequence as long as a specified condition is true and then returns the remaining elements.
Declaration
Swift
public func skip(while predicate: @escaping (Element) throws -> Bool) -> Infallible<Element>
Parameters
predicate
A function to test each element for a condition.
Return Value
An infallible 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.
-
skip(until:
Extension method) Returns the elements from the source infallible sequence that are emitted after the other infallible sequence produces an element.
Declaration
Swift
public func skip<Source: ObservableType>(until other: Source) -> Infallible<Element>
Parameters
other
Infallible sequence that starts propagation of elements of the source sequence.
Return Value
An infallible sequence containing the elements of the source sequence that are emitted after the other sequence emits an item.
-
share(replay:
Extension methodscope: ) Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays elements in buffer.
This operator is equivalent to:
.whileConnected
// Each connection will have it's own subject instance to store replay events. // Connections will be isolated from each another. source.multicast(makeSubject: { Replay.create(bufferSize: replay) }).refCount()
.forever
// One subject will store replay events for all connections to source. // Connections won't be isolated from each another. source.multicast(Replay.create(bufferSize: replay)).refCount()
It uses optimized versions of the operators for most common operations.
Declaration
Swift
public func share(replay: Int = 0, scope: SubjectLifetimeScope = .whileConnected) -> Infallible<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.
-
withUnretained(_:
Extension methodresultSelector: ) Provides an unretained, safe to use (i.e. not implicitly unwrapped), reference to an object along with the events emitted by the sequence.
In the case the provided object cannot be retained successfully, the sequence will complete.
Note
Be careful when using this operator in a sequence that has a buffer or replay, for example
share(replay: 1)
, as the sharing buffer will also include the provided object, which could potentially cause a retain cycle.Declaration
Swift
public func withUnretained<Object: AnyObject, Out>( _ obj: Object, resultSelector: @escaping (Object, Element) -> Out ) -> Infallible<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 onobj
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
public func withUnretained<Object>(_ obj: Object) -> Infallible<(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.
-
withLatestFrom(_:
Extension methodresultSelector: ) Merges two observable sequences into one observable sequence by combining each element from self with the latest element from the second source, if any.
Note
Elements emitted by self before the second source has emitted any values will be omitted.
Declaration
Swift
public func withLatestFrom<Source, ResultType>(_ second: Source, resultSelector: @escaping (Element, Source.Element) throws -> ResultType) -> Infallible<ResultType> where Source : InfallibleType
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.Note
Elements emitted by self before the second source has emitted any values will be omitted.
Declaration
Swift
public func withLatestFrom<Source>(_ second: Source) -> Infallible<Source.Element> where Source : InfallibleType
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.
-
zip(_:
Extension method_: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2>(_ source1: Infallible<E1>, _ source2: Infallible<E2>, resultSelector: @escaping (E1, E2) throws -> Element) -> Infallible<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(_:
Extension method_: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3>(_ source1: Infallible<E1>, _ source2: Infallible<E2>, _ source3: Infallible<E3>, resultSelector: @escaping (E1, E2, E3) throws -> Element) -> Infallible<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(_:
Extension method_: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4>(_ source1: Infallible<E1>, _ source2: Infallible<E2>, _ source3: Infallible<E3>, _ source4: Infallible<E4>, resultSelector: @escaping (E1, E2, E3, E4) throws -> Element) -> Infallible<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(_:
Extension method_: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5>(_ source1: Infallible<E1>, _ source2: Infallible<E2>, _ source3: Infallible<E3>, _ source4: Infallible<E4>, _ source5: Infallible<E5>, resultSelector: @escaping (E1, E2, E3, E4, E5) throws -> Element) -> Infallible<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(_:
Extension method_: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6>(_ source1: Infallible<E1>, _ source2: Infallible<E2>, _ source3: Infallible<E3>, _ source4: Infallible<E4>, _ source5: Infallible<E5>, _ source6: Infallible<E6>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6) throws -> Element) -> Infallible<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(_:
Extension method_: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7>(_ source1: Infallible<E1>, _ source2: Infallible<E2>, _ source3: Infallible<E3>, _ source4: Infallible<E4>, _ source5: Infallible<E5>, _ source6: Infallible<E6>, _ source7: Infallible<E7>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6, E7) throws -> Element) -> Infallible<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(_:
Extension method_: _: _: _: _: _: _: resultSelector: ) Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
Seealso
Declaration
Swift
public static func zip<E1, E2, E3, E4, E5, E6, E7, E8>(_ source1: Infallible<E1>, _ source2: Infallible<E2>, _ source3: Infallible<E3>, _ source4: Infallible<E4>, _ source5: Infallible<E5>, _ source6: Infallible<E6>, _ source7: Infallible<E7>, _ source8: Infallible<E8>, resultSelector: @escaping (E1, E2, E3, E4, E5, E6, E7, E8) throws -> Element) -> Infallible<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.
-
subscribe(with:
Extension methodonNext: onCompleted: onDisposed: ) Subscribes an element handler, a completion handler and disposed handler to an observable sequence.
Error callback is not exposed because
Infallible
can’t error out.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
public func subscribe<Object: AnyObject>( with object: Object, onNext: ((Object, Element) -> 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.
onCompleted
Action to invoke upon graceful termination of the observable sequence. gracefully completed, errored, or if the generation is canceled by disposing subscription)
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:
Extension methodonCompleted: onDisposed: ) Subscribes an element handler, a completion handler and disposed handler to an observable sequence.
Error callback is not exposed because
Infallible
can’t error out.Declaration
Swift
public func subscribe(onNext: ((Element) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) -> Disposable
Parameters
onNext
Action to invoke for each element in the observable sequence.
onCompleted
Action to invoke upon graceful termination of the observable sequence. gracefully completed, errored, or if the generation is canceled by disposing subscription)
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(_:
Extension method) Subscribes an event handler to an observable sequence.
Declaration
Swift
public func subscribe(_ on: @escaping (InfallibleEvent<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.
-
combineLatest(_:
Extension method_: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: InfallibleType, O2: InfallibleType> (_ source1: O1, _ source2: O2) -> Infallible<(O1.Element, O2.Element)>
Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:
Extension method_: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: InfallibleType, O2: InfallibleType, O3: InfallibleType> (_ source1: O1, _ source2: O2, _ source3: O3) -> Infallible<(O1.Element, O2.Element, O3.Element)>
Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:
Extension method_: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: InfallibleType, O2: InfallibleType, O3: InfallibleType, O4: InfallibleType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4) -> Infallible<(O1.Element, O2.Element, O3.Element, O4.Element)>
Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:
Extension method_: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: InfallibleType, O2: InfallibleType, O3: InfallibleType, O4: InfallibleType, O5: InfallibleType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5) -> Infallible<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element)>
Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:
Extension method_: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: InfallibleType, O2: InfallibleType, O3: InfallibleType, O4: InfallibleType, O5: InfallibleType, O6: InfallibleType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6) -> Infallible<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element)>
Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:
Extension method_: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: InfallibleType, O2: InfallibleType, O3: InfallibleType, O4: InfallibleType, O5: InfallibleType, O6: InfallibleType, O7: InfallibleType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7) -> Infallible<(O1.Element, O2.Element, O3.Element, O4.Element, O5.Element, O6.Element, O7.Element)>
Return Value
An observable sequence containing the result of combining elements of the sources.
-
combineLatest(_:
Extension method_: _: _: _: _: _: _: ) Merges the specified observable sequences into one observable sequence of tuples whenever any of the observable sequences produces an element.
Declaration
Swift
public static func combineLatest<O1: InfallibleType, O2: InfallibleType, O3: InfallibleType, O4: InfallibleType, O5: InfallibleType, O6: InfallibleType, O7: InfallibleType, O8: InfallibleType> (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8) -> Infallible<(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.
-
distinctUntilChanged()
Extension methodReturns an observable sequence that contains only distinct contiguous elements according to equality operator.
Declaration
Swift
public func distinctUntilChanged() -> Infallible<Element>
Return Value
An observable sequence only containing the distinct contiguous elements, based on equality operator, from the source sequence.