Skip to content

Commit

Permalink
Fix double cancellation of Shared.Subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrtsa committed Nov 14, 2024
1 parent bc4d685 commit f9e82e9
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension Shared {
/// This object is returned from ``PersistenceReaderKey/subscribe(initialValue:didSet:)``, which
/// will feed updates from an external system for its lifetime, or till ``cancel()`` is called.
public class Subscription {
let onCancel: () -> Void
var onCancel: (() -> Void)?

/// Initializes the subscription with the given cancel closure.
///
Expand All @@ -88,7 +88,8 @@ extension Shared {

/// Cancels the subscription.
public func cancel() {
self.onCancel()
self.onCancel?()
self.onCancel = nil
}
}
}

0 comments on commit f9e82e9

Please sign in to comment.