1 min readOct 20, 2019
In one of the later betas Combine added a “disposeBag” mechanism with a type-erased AnyCancellable that automatically deinits.
var subscriptions = Set<AnyCancellable>()somePublisher
.sink(receiveValue: { data in
...
})
.store(in: &subscriptions)
Builder mechanism is nice, though. Could add it as an extension to Set where type is AnyCancellable.
Though, come to think of it…
subscriptions.formUnion([
p.sink(receiveValue: { print($0) }),
p.sink(receiveValue: { print($0) })
])
Appreciated the link back, btw.