Open ibsh opened 4 years ago
Good idea @ibsh! I've added store(in:)
family of methods that are more aligned with Apple's Combine in the latest release.
extension Disposable {
public func dispose(in disposeBag: DisposeBagProtocol) {
disposeBag.add(disposable: self)
}
public func store(in disposeBag: DisposeBagProtocol) {
disposeBag.add(disposable: self)
}
public func store<C>(in collection: inout C) where C: RangeReplaceableCollection, C.Element == AnyCancellable {
collection.append(AnyCancellable(self))
}
public func store(in set: inout Set<AnyCancellable>) {
set.insert(AnyCancellable(self))
}
}
The shared verb between this method and Disposable.dispose() makes them appear extremely similar in behaviour.
I suggest RxSwift's
.disposed(by:)