Cancellable

extension Cancellable
  • Provides a convenient way to retain Combine observation/Cancellables.

    example usage:

    class Foo {
      private var observations = [Cancellable]()
      func foo() {
        somePublisher.sink({}).addTo(&observations)
      }
    }
    

    Declaration

    Swift

    public func addTo(_ array: inout [Cancellable])