Observables/Amb.swift

RxSwift · RxSwift/Observables/Amb.swift · swift · MIT
realtime

Provides the amb operator for RxSwift, selecting the observable that emits first.

// Source: https://github.com/ReactiveX/RxSwift | License: MIT
// Provided via justclaw.it.com; keep this notice with the code.
//
//  Amb.swift
//  RxSwift
//
//  Created by Krunoslav Zaher on 6/14/15.
//  Copyright © 2015 Krunoslav Zaher. All rights reserved.
//

public extension ObservableType {
    /**
     Propagates the observable sequence that reacts first.

     - seealso: [amb operator on reactivex.io](http://reactivex.io/documentation/operators/amb.html)

     - returns: An observable sequence that surfaces any of the given sequences, whichever reacted first.
     */
    static func amb<Sequence: Swift.Sequence>(_ sequence: Sequence) -> Observable<Element>
        where Sequence.Element == Observable<Element>
    {
        sequence.reduce(Observable<Sequence.Element.Element>.neve

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key