-
Notifications
You must be signed in to change notification settings - Fork 432
Description
I'm currently learning the project while trying to understand every single bit of it.
As far as I understood the design of Disposable
types included in the Disposable.swift
file, I think I might have found a small issue (maybe harmless, but potentially a bug?).
For example CompositeDisposable
will clear the Atomic
's value and potentially remove all the retained references to the Disposable
objects. Then if you try to add a new disposable to the CompositeDisposable
, but the CompositeDisposable
itself is already disposed, it will dispose the passed Disposable
and reject retaining the reference into the bag.
Now if I compare that behavior with SerialDisposable
, the dispose()
method does the same. However the setter on the inner
property does not reject the value if the SerialDisposable
is already disposed, but retains the reference.
Is this by design or just overlooked?
I thought it would be more like this:
set(disposable) {
+ if isDisposed {
+ disposable?.dispose() // Dispose and do not retain
+ } else {
_inner.swap(disposable)?.dispose()
+ }
-
- if let disposable = disposable, isDisposed {
- disposable.dispose()
- }
}