Last active
July 12, 2018 06:06
-
-
Save sgtsquiggs/0b1dc9dbd6fe51f107d4082ac7c448cd to your computer and use it in GitHub Desktop.
Bind an observable to a collection of observers at once.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RxSwift | |
extension ObservableType { | |
func bind<O>(to observers: [O]) -> Disposable where O: ObserverType, Self.E == O.E { | |
let shared = self.share() | |
let disposables = observers.map(shared.bind(to:)) | |
return CompositeDisposable(disposables: disposables) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment