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.
16 lines
452 B
Swift
16 lines
452 B
Swift
import PromiseKit
|
|
|
|
public extension AnyPromise {
|
|
|
|
/// Sometimes there isn't a straightforward candidate to retain a promise. In that case we tell the
|
|
/// promise to self retain until it completes, to avoid the risk it's GC'd before completion.
|
|
@objc
|
|
func retainUntilComplete() {
|
|
var retainCycle: AnyPromise? = self
|
|
_ = self.ensure {
|
|
assert(retainCycle != nil)
|
|
retainCycle = nil
|
|
}
|
|
}
|
|
}
|