-
-
Save amine2233/6345f8a1b9ad9e76c4b6cfab71eb2aa9 to your computer and use it in GitHub Desktop.
Combine assign method without the memory leak
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
extension Publisher where Self.Failure == Never { | |
public func assignNoRetain<Root>(to keyPath: ReferenceWritableKeyPath<Root, Self.Output>, on object: Root) -> AnyCancellable where Root: AnyObject { | |
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