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 226bbdf commit b9a9bf5
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ extension Shared {
///
/// - Parameter cancel: A closure that the `cancel()` method executes.
public init(_ cancel: @escaping () -> Void) {
self.onCancel = cancel
var cancelled = true
self.onCancel = {
guard !cancelled else { return }
cancelled = true
cancel()
}
}

deinit {
Expand Down

0 comments on commit b9a9bf5

Please sign in to comment.