Skip to content

Commit

Permalink
DisposableBag conforms now to Disposable protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanko Dimitrov committed Jan 29, 2016
1 parent 28befa3 commit d78dec6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions SignalKit/Utilities/DisposableBag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ extension DisposableBag {
return bag.count
}
}

extension DisposableBag: Disposable {

public func dispose() {

removeAll()
}
}
12 changes: 12 additions & 0 deletions SignalKitTests/Utilities/DisposableBagTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ class DisposableBagTests: XCTestCase {

XCTAssertEqual(disposable.isDisposeCalled, true, "Should remove and dispose all disposables on deinit")
}

func testDispose() {

let signalTwo = MockSignal<String>()

bag.addDisposable(signal)
bag.addDisposable(signalTwo)

bag.dispose()

XCTAssertEqual(bag.count, 0, "Should remove all signals from the bag")
}
}

0 comments on commit d78dec6

Please sign in to comment.