[Swift 3.0] Rename disposable-related methods
Rename Some methods to better match Swift 3.0 API Design Guidelines.
Methods will old name will still exist for a while with a deprecation annotation.
This is a summary of the proposed changes:
extension CompositeDisposable {
+ @available(*, renamed: "insert()")
public func addDisposable(_ disposable: Disposable) -> DisposeKey?
+ public func insert(_ disposable: Disposable) -> DisposeKey?
+ @available(*, renamed: "removeDisposable(forKey:)")
public func removeDisposable(_ disposeKey: DisposeKey)
+ public func removeDisposable(forKey disposeKey: DisposeKey)
}
extension DisposeBag {
+ @available(*, renamed: "insert()")
public func addDisposable(_ disposable: Disposable)
+ public func insert(_ disposable: Disposable)
}
+@available(*, renamed: "Bag.disposeAll()")
public func disposeAllIn(_ bag: Bag<Disposable>)
+extension Bag where T: Disposable {
+
+ public func disposeAll()
+
+}
The last renaming doesn’t work as the compiler can’t produce call to Bag<Disposable> when not using a concrete subtype. Instead, we have:
+@available(*, renamed: "disposeAll(in:)")
public func disposeAllIn(_ bag: Bag<Disposable>)
+public func disposeAll(in bag: Bag<Disposable>)
Hey,
yeah, I think your suggestions make sense.
The one change I would suggest is using
public func remove(forKey disposeKey: DisposeKey)
instead of
public func removeDisposable(forKey disposeKey: DisposeKey)
... so there is no redundant Disposable.
I modelled that on Dictionary.removeValue(forKey:) cause its the closest API for what we’re doing here.
Though you’re right that the shorter name feels better. Specially given that the type is not parameterised. Maybe we should parallel with Array.remove(at:): so we’d have remove(for:) – unless you think the Key part is needed?
@mohsenr yeah, my reasoning was because of array.remove(at:).
I'm fine with remove(for:) suggestion.