Let’s say you are using the built-in .store(in:) method on AnyCancellable like so:
private var subscriptions = Set<AnyCancellable>()
let newPhotos = photos.selectedPhotos
newPhotos
.map { [unowned self] newImage in
return self.images.value + [newImage]
}
.assign(to: \.value, on: images)
.store(in: &subscriptions)
If you have an app that does this a lot - are these removed when the publishers complete?
Also, If i decide to go with this approach instead:
private var newPhotosSubscription: AnyCancellable?
self.newPhotosSubscription = newPhotos
.map { [unowned self] newImage in
self.images.value + [newImage]
}
.assign(to: \.value, on: images)
Everytime I call the method again, it override the AnyCancellable, what happens to the previous one? Does it still complete before being deallocated?