-
-
Save jasdev/201a9d80ce558a16ecf142eb45bd2638 to your computer and use it in GitHub Desktop.
`Publisher.assign(to:onWeak:)`.
This file contains hidden or 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 | |
extension Publisher where Failure == Never { | |
func assign<Root: AnyObject>( | |
to keyPath: ReferenceWritableKeyPath<Root, Output>, | |
onWeak object: Root | |
) -> AnyCancellable { | |
sink { [weak object] value in | |
object?[keyPath: keyPath] = value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment