ScopedDisposable
public final class ScopedDisposable<Inner> : Disposable where Inner : Disposable
A disposable that, upon deinitialization, will automatically dispose of its inner disposable.
-
The disposable which will be disposed when the ScopedDisposable deinitializes.
Declaration
Swift
public let inner: Inner
-
Declaration
Swift
public var isDisposed: Bool { get }
-
Initialize the receiver to dispose of the argument upon deinitialization.
Declaration
Swift
public init(_ disposable: Inner)
Parameters
disposable
A disposable to dispose of when deinitializing.
-
Declaration
Swift
public func dispose()
-
Initialize the receiver to dispose of the argument upon deinitialization.
Declaration
Swift
public convenience init(_ disposable: Disposable)
Parameters
disposable
A disposable to dispose of when deinitializing, which will be wrapped in an
AnyDisposable
.
-
Adds the right-hand-side disposable to the left-hand-side
ScopedDisposable<CompositeDisposable>
.disposable += { ... }
Declaration
Swift
@discardableResult public static func += (lhs: ScopedDisposable<CompositeDisposable>, rhs: Disposable?) -> Disposable?
Parameters
lhs
Disposable to add to.
rhs
Disposable to add.
Return Value
An instance of
DisposableHandle
that can be used to opaquely remove the disposable later (if desired). -
Adds the right-hand-side disposable to the left-hand-side
ScopedDisposable<CompositeDisposable>
.disposable += { ... }
Declaration
Swift
@discardableResult public static func += (lhs: ScopedDisposable<CompositeDisposable>, rhs: @escaping () -> Void) -> Disposable?
Parameters
lhs
Disposable to add to.
rhs
Closure to add as a disposable.
Return Value
An instance of
DisposableHandle
that can be used to opaquely remove the disposable later (if desired).