-
-
Save jasdev/5705e0587880b6beedb17ac4c066209b to your computer and use it in GitHub Desktop.
Example of weak assignment.
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
final class SomeViewModel: ObservableObject { | |
// MARK: - Outputs | |
@Published var someProperty = () | |
// MARK: - Private | |
private var subscriptions = Set<AnyCancellable>() | |
init() { | |
somePublisher | |
.assign(to: \.someProperty, onWeak: self) | |
.store(in: &subscriptions) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment