Skip to content

Instantly share code, notes, and snippets.

@gkaimakas
Created June 21, 2019 14:50
Show Gist options
  • Save gkaimakas/4bb1834a93e6231ecc1ccf9ee9cfdb39 to your computer and use it in GitHub Desktop.
Save gkaimakas/4bb1834a93e6231ecc1ccf9ee9cfdb39 to your computer and use it in GitHub Desktop.
import Combine
/// Naming and idea where taken from ReactiveSwift
precedencegroup BindingPrecedence {
associativity: right
// Binds tighter than assignment but looser than everything else
higherThan: AssignmentPrecedence
}
infix operator <~ : BindingPrecedence
extension Publisher where Failure == Never {
static func <~<S>(subject: S, publisher: Self) -> Cancellable where S: Subject, S.Failure == Never, S.Output == Self.Output {
return publisher.subscribe(subject)
}
static func <~<S> (subscriber: S, publisher: Self) where S: Subscriber, S.Failure == Never, S.Input == Self.Output {
publisher.subscribe(subscriber)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment