Last active
July 2, 2023 11:06
-
-
Save woodycatliu/9ccb4d87a793c6a5c0894ba3d2ff935e to your computer and use it in GitHub Desktop.
CurrentValueSubject init from AnyPublisher and avoid retain cycle
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 | |
extension CurrentValueSubject where Failure == Never { | |
convenience init(with publisher: AnyPublisher<Output, Failure>, value: Output) { | |
self.init(value) | |
publisher.receive(subscriber: AnySubscriber(self)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment