-
Notifications
You must be signed in to change notification settings - Fork 212
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
[Vote] Naming for Operators that target Collections/Arrays #168
Comments
@RxSwiftCommunity/contributors - Feedback would be highly appreciated! |
I personally feel that |
We already have |
One thing that would have been very nice is that This said, and regardless the performance issues with tooling which may resolve themselves in a decade or two, My second choice is what @icanzilb mentioned: |
@fpillet To be honest that PR (#166) defines a variadic companion. This might be a good thing to try to pursue on the main repo, possibly. We can do it in a relatively backwards compatible way, like this: public func bind<O: ObserverType>(to observers: O...) -> Disposable where O.E == E {
return self.bind(to: observers)
}
public func bind<O: ObserverType>(to observers: [O]) -> Disposable where Self.E == O.E {
switch observers.count {
case 1:
return self.subscribe(observers[0])
default:
let shared = self.share()
let disposables = observers.map(shared.subscribe)
return CompositeDisposable(disposables: disposables)
}
} Think this could possibly be a good idea for a PR on the main repo. What do you think? @fpillet |
Opened a basic PR for discussion here: |
@freak4pc |
We can add it but it doesn’t really make sense / is aligned with swift naming convention IMO |
|
If that was the case, the original operator would be called I don't know any place in stdlib or Swift in general where the |
If have to stick strictly to swift convention we wouldn't invent anything. IMO |
Yes but when it comes to naming convention it needs to convey clarity, intent, and known practices of Swift. in: usually refers to references, or when you “look something up”, but not to describe applying something to many elements IMO. |
In that case we can use |
The only thing is it doesn’t sound like a proper English sentence, grammatically speaking. Which is what we should strive for. Bind to (an) array sounds fine In any sense, if Krunoslav would agree having the variadic option it would solve overloads since there would be a single option. |
Ok then we should speak proper English then at this point. How about |
The problem with into is that in Swift it’s usually used for “In place mutation” (see reduce(into:) ) Not meaning to be anti your suggestion, but finding a good option for drive that makes good grammatical and syntactical sense would be quite hard. |
@freak4pc not at all we're just brainstorming on names. I've exhausted my names.. but |
I’m aware of that precedent. Overloading works much better but is still the least preferable way to go, IMO. Unless it would be in high demand, which it doesn’t seem to be at this point. |
We're trying to figure out a good naming scheme for operators that target a collection of something.
For example, like our existing
mapMany
operator. One of the newer ones isbind(to: [..])
, vs.bindMany(...)
.The big question is, should we keep on doing
*many
, or should we use overloads. The cost of overloads mainly comes down to performance, indexing, collision-issues, etc.Please cast your vote!
The text was updated successfully, but these errors were encountered: