-
Notifications
You must be signed in to change notification settings - Fork 26
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
Channel: consistent publish
methods between other platform clients
#121
Comments
Agreed, renamed to |
@mattheworiordan Well, it is a good practice but with Swift it might be better. The result with the change: Objective-C [channel publish:@"event" data:nil callback:nil];
[channel publish:@[message1, message2] callback:nil]; Swift channel.publish("event", data: nil, callback: nil)
channel.publish([message1, message2], callback: nil) |
I'm not sure what is our "policy" about preferring Ably conventions vs. language conventions. I think we favor the former, right? For example, I've seen that the Go library takes callbacks for async operations, which is really not Go-y. That favors uniformity on documentation I guess, so you can apply doc resources written for one language to one trivially, but it makes it uglier and maybe more difficult to actually use the libraries. So I think I prefer the latter, but what's really important is to be consistent, so if we're doing the former elsewhere, I'm OK with this change. |
Yup, we use channels normally. Our policy is to where sensible keep as consistent as possible with the API, however, we do use idiomatic forms for every language where it feels "wrong" to use our more generic API. So there is no right or wrong answer, however, if overloading in Objective-C is not wrong nor bad, but perhaps just not typical, then I would personally opt for the overloaded approach that @ricardopereira has provided. @tcard or @ricardopereira do you feel overloading like this, for Objective-C developers, would feel wrong, or perhaps just not normal but OK? |
There are strict conventions to follow for some method names: accessor method names & object constructors method names. But anything else is just fine... Apple just want to sell the expressivity of Objective-C. By the rules it should be something like: - (void)publish:(art_nullable id)payload callback:(art_nullable ARTErrorCallback)callback;
- (void)publishWithName:(art_nullable NSString *)name payload(art_nullable id)payload callback:(art_nullable ARTErrorCallback)callback;
- (void)publishWithMessage:(ARTMessage *)message callback:(art_nullable ARTErrorCallback)callback;
- (void)publishWithMessages:(__GENERIC(NSArray, ARTMessage *) *)messages callback:(art_nullable ARTErrorCallback)callback; So, I would say it is not normal but it is ok. We just need to take in mind to create unique methods within a class. The translation of Objective-C to Swift help us to guarantee that. |
Ok, well if it's normal but OK I personally would prefer to remain closer to our intended API, thanks @ricardopereira |
Yeah, I guess it's not that bad. |
Fixed by 97f0b16. |
Current publish methods
Should be something like
I am assuming renaming
ARTErrorCallback
toARTPublishCallback
.ARTErrorCallback
feels like it is a callback when something fails and it is not.The text was updated successfully, but these errors were encountered: