Skip to content

Instantly share code, notes, and snippets.

@hermanbanken
Created June 5, 2019 13:33
Show Gist options
  • Select an option

  • Save hermanbanken/b9d07a984fc8cc34943803e98787d286 to your computer and use it in GitHub Desktop.

Select an option

Save hermanbanken/b9d07a984fc8cc34943803e98787d286 to your computer and use it in GitHub Desktop.
extension Observable : Publisher {
@available(iOS 13.0, *)
public func receive<S>(subscriber: S) where S : Subscriber, Observable.Failure == S.Failure, Observable.Output == S.Input {
_ = self.subscribe(onNext: { (next) in
let demand = subscriber.receive(next)
}, onError: { (err) in
subscriber.receive(completion: .failure(err))
}, onCompleted: {
subscriber.receive(completion: .finished)
})
}
public typealias Failure = Error
public typealias Output = Element
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment