understandingCombine
understandingCombine copied to clipboard
Typo in code example
In Subjects
var storage = Set<AnyCancellable>() let topSubject = PassthroughSubject<String,Never>() override func viewDidLoad() { super.viewDidLoad() let sub1 = PassthroughSubject<String,Never>() topSubject.subscribe(sub1) .store(in:&self.storage) sub1.sink { print("sub1", $0)} .store(in:&self.storage) let sub12 = PassthroughSubject<String,Never>() topSubject.subscribe(sub12) .store(in:&self.storage) sub1.sink { print("sub2", $0)} .store(in:&self.storage) }
You subscribe twice to sub1. And sub12 should probably be sub2