Created
June 21, 2019 14:50
-
-
Save gkaimakas/4bb1834a93e6231ecc1ccf9ee9cfdb39 to your computer and use it in GitHub Desktop.
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 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