Skip to content

Instantly share code, notes, and snippets.

@sgtsquiggs
Last active July 12, 2018 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgtsquiggs/0b1dc9dbd6fe51f107d4082ac7c448cd to your computer and use it in GitHub Desktop.
Save sgtsquiggs/0b1dc9dbd6fe51f107d4082ac7c448cd to your computer and use it in GitHub Desktop.
Bind an observable to a collection of observers at once.
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