Skip to content

Instantly share code, notes, and snippets.

@jasdev jasdev/assign_retain_cycle.swift Secret
Last active Apr 8, 2020

What would you like to do?
Example `assign` retain cycle.
import Combine
final class SomeViewModel: ObservableObject {
// MARK: - Outputs
@Published var someProperty = () /// (1) Using `Void` for sake of example.
// MARK: - Private
private var subscriptions = Set<AnyCancellable>()
init() {
somePublisher /// (2) of `Output` type `Void` and `Never`-valued `Failure`.
.assign(to: \.someProperty, on: self) /// (3) Accidental `strong` catpture of `self`.
.store(in: &subscriptions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.