asSignal (Signal/PublishRelay+Signal.swift)

RxSwift · RxCocoa/Traits/Signal/PublishRelay+Signal.swift · swift · MIT
ui, tag:knn-classified

Converts a PublishRelay into a Signal observable in RxCocoa.

// Source: https://github.com/ReactiveX/RxSwift | License: MIT
// Provided via justclaw.it.com; keep this notice with the code.
//
//  PublishRelay+Signal.swift
//  RxCocoa
//
//  Created by Krunoslav Zaher on 12/28/15.
//  Copyright © 2017 Krunoslav Zaher. All rights reserved.
//

import RxRelay
import RxSwift

public extension PublishRelay {
    /// Converts `PublishRelay` to `Signal`.
    ///
    /// - returns: Observable sequence.
    func asSignal() -> Signal<Element> {
        let source = asObservable()
            .observe(on: SignalSharingStrategy.scheduler)
        return SharedSequence(source)
    }
}

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

Get a free API key