mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
922 B
Swift
46 lines
922 B
Swift
5 years ago
|
import PromiseKit
|
||
|
|
||
|
public extension AnyPromise {
|
||
|
|
||
4 years ago
|
@objc func retainUntilComplete() {
|
||
5 years ago
|
var retainCycle: AnyPromise? = self
|
||
|
_ = self.ensure {
|
||
|
assert(retainCycle != nil)
|
||
|
retainCycle = nil
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public extension PMKFinalizer {
|
||
|
|
||
|
func retainUntilComplete() {
|
||
|
var retainCycle: PMKFinalizer? = self
|
||
|
self.finally {
|
||
|
assert(retainCycle != nil)
|
||
|
retainCycle = nil
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public extension Promise {
|
||
|
|
||
|
func retainUntilComplete() {
|
||
|
var retainCycle: Promise<T>? = self
|
||
|
_ = self.ensure {
|
||
|
assert(retainCycle != nil)
|
||
|
retainCycle = nil
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public extension Guarantee {
|
||
|
|
||
|
func retainUntilComplete() {
|
||
|
var retainCycle: Guarantee<T>? = self
|
||
|
_ = self.done { _ in
|
||
|
assert(retainCycle != nil)
|
||
|
retainCycle = nil
|
||
|
}
|
||
|
}
|
||
|
}
|