Skip to content
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

Suggestion: rename Disposable.dispose(in:) #244

Open
ibsh opened this issue Dec 9, 2019 · 1 comment
Open

Suggestion: rename Disposable.dispose(in:) #244

ibsh opened this issue Dec 9, 2019 · 1 comment

Comments

@ibsh
Copy link

ibsh commented Dec 9, 2019

The shared verb between this method and Disposable.dispose() makes them appear extremely similar in behaviour.

I suggest RxSwift's .disposed(by:)

@srdanrasic
Copy link
Contributor

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))
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants