-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: make DisposeBag a noncopyable type in RxSwift 7 #2633
Comments
Hey there - It's an interesting discussion which I've considered but indeed making them mutable and inout is a large change. The change doesn't seem valuable enough to me for its related costs. At least my personal opinion around this. |
@freak4pc thanks for your feedback! Btw, it looks like the mutability/inout argument can be avoided if the implementation is kept as it is in POC now, where a noncopyable struct uses a class instance under the hood. The reason I added |
Right, totally understand - LMK if you feel comfortable closing this for now. |
@freak4pc fair enough, I'm fine closing it. |
As far as my experience goes, dispose bags are usually attached to a single object's lifetime and (are supposted to) deinit with it.
Making
DisposeBag
a noncopyable type enforce this 1:1 relation and will prevent potential misuses, like passingDisposeBag
around and retaining it somewhere accidentally, at compile time.The obvious downside is code churn associated with it, because:
var
to be usable (unless all disposables are passed once on bag's creation).disposed(by: bag)
calls will have to become.disposed(by: &bag)
But the above seems acceptable for a major release.
I'd appreciate your opinions and use cases that I didn't mention that may become problematic with
DisposeBag
being noncopyable.PoC: #2634.
The text was updated successfully, but these errors were encountered: