Group Group Group Group Group Group Group Group Group

AnyCancellable.store(in:) - when and how are these removed

Let’s say you are using the built-in .store(in:) method on AnyCancellable like so:


example(of: "removeDuplicates") {
  // 1
  let words = "hey hey there! want to listen to mister mister ?"
                  .components(separatedBy: " ")
                  .publisher
  // 2
  words
    .removeDuplicates()
    .sink(receiveValue: { print($0) })
    .store(in: &subscriptions)
}

If you have an app that does this a lot - are these removed when the publishers complete?

I assume not - but wanted to double check. It also seems that this storage wouldn’t be thread-safe, correct?

2 Likes

@tourultimate Do you still have issues with this?

I haven’t tested to confirm but I’m basically working off of my assumptions above at this point. If somebody knows for sure, that would be helpful.