Skip to content
Snippets Groups Projects
Commit 5808d986 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

FIx Cancellable

Prevent multiple cancellations
parent 5e876231
No related branches found
No related tags found
1 merge request!10Fix Cancellable
public final class Cancellable {
public init(cancel: @escaping () -> Void) {
self.cancel = cancel
self.onCancel = cancel
}
deinit {
cancel()
}
public let cancel: () -> Void
public func cancel() {
guard isCancelled == false else { return }
isCancelled = true
onCancel()
}
private var isCancelled = false
private let onCancel: () -> Void
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment