DisposeBag

public final class DisposeBag : DisposeBase

Thread safe bag that disposes added disposables on deinit.

This returns ARC (RAII) like resource management to RxSwift.

In case contained disposables need to be disposed, just put a different dispose bag or create a new one in its place.

self.existingDisposeBag = DisposeBag()

In case explicit disposal is necessary, there is also CompositeDisposable.

  • Constructs new empty dispose bag.

    Declaration

    Swift

    public override init()
  • Adds disposable to be disposed when dispose bag is being deinited.

    Declaration

    Swift

    public func insert(_ disposable: Disposable)

    Parameters

    disposable

    Disposable to add.

  • Convenience init allows a list of disposables to be gathered for disposal.

    Declaration

    Swift

    public convenience init(disposing disposables: Disposable...)
  • Convenience init which utilizes a function builder to let you pass in a list of disposables to make a DisposeBag of.

    Declaration

    Swift

    public convenience init(@DisposeBag.DisposableBuilder builder: () -> [Disposable])
  • Convenience init allows an array of disposables to be gathered for disposal.

    Declaration

    Swift

    public convenience init(disposing disposables: [Disposable])
  • Convenience function allows a list of disposables to be gathered for disposal.

    Declaration

    Swift

    public func insert(_ disposables: Disposable...)
  • Convenience function allows a list of disposables to be gathered for disposal.

    Declaration

    Swift

    public func insert(@DisposeBag.DisposableBuilder builder: () -> [Disposable])
  • Convenience function allows an array of disposables to be gathered for disposal.

    Declaration

    Swift

    public func insert(_ disposables: [Disposable])
  • A function builder accepting a list of Disposables and returning them as an array.

    See more

    Declaration

    Swift

    @resultBuilder
    public struct DisposableBuilder