CompositeDisposable

public final class CompositeDisposable : Disposable

A disposable that will dispose of any number of other disposables.

  • Declaration

    Swift

    public var isDisposed: Bool { get }
  • Initialize a CompositeDisposable containing the given sequence of disposables.

    Declaration

    Swift

    public init<S>(_ disposables: S) where S : Sequence, S.Element == Disposable

    Parameters

    disposables

    A collection of objects conforming to the Disposable protocol

  • Initialize a CompositeDisposable containing the given sequence of disposables.

    Declaration

    Swift

    public convenience init<S: Sequence>(_ disposables: S)
    	where S.Iterator.Element == Disposable?

    Parameters

    disposables

    A collection of objects conforming to the Disposable protocol

  • Initializes an empty CompositeDisposable.

    Declaration

    Swift

    public convenience init()
  • Declaration

    Swift

    public func dispose()
  • Add the given disposable to the composite.

    Declaration

    Swift

    @discardableResult
    public func add(_ disposable: Disposable?) -> Disposable?

    Parameters

    disposable

    A disposable.

    Return Value

    A disposable to remove disposable from the composite. nil if the composite has been disposed of, disposable has been disposed of, or disposable is nil.

  • Add the given action to the composite.

    Declaration

    Swift

    @discardableResult
    public func add(_ action: @escaping () -> Void) -> Disposable?

    Parameters

    action

    A closure to be invoked when the composite is disposed of.

    Return Value

    A disposable to remove disposable from the composite. nil if the composite has been disposed of, disposable has been disposed of, or disposable is nil.

  • Adds the right-hand-side disposable to the left-hand-side CompositeDisposable.

     disposable += producer
         .filter { ... }
         .map    { ... }
         .start(observer)
    

    Declaration

    Swift

    @discardableResult
    public static func += (lhs: 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 ActionDisposable to the left-hand-side CompositeDisposable.

    disposable += { ... }
    

    Declaration

    Swift

    @discardableResult
    public static func += (lhs: 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).