Skip to content

Commit

Permalink
Merge pull request #281 from ably/rename-cb-callback
Browse files Browse the repository at this point in the history
Renamed last cb: argument to callback:
  • Loading branch information
ricardopereira committed Mar 8, 2016
2 parents e62f458 + bb4275c commit c9b7b34
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Source/ARTPresenceMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ - (BOOL)isSyncComplete {
return self.syncStarted && self.syncComplete;
}

- (BOOL) stillSyncing {
return self.syncStarted && ! self.syncComplete;
- (BOOL)stillSyncing {
return self.syncStarted && !self.syncComplete;
}

#pragma mark private
Expand Down
6 changes: 3 additions & 3 deletions Source/ARTRealtimeChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ ART_ASSUME_NONNULL_BEGIN
@property (readonly, getter=getPresence) ARTRealtimePresence *presence;

- (void)attach;
- (void)attach:(art_nullable void (^)(ARTErrorInfo *__art_nullable))cb;
- (void)attach:(art_nullable void (^)(ARTErrorInfo *__art_nullable))callback;

- (void)detach;
- (void)detach:(art_nullable void (^)(ARTErrorInfo *__art_nullable))cb;
- (void)detach:(art_nullable void (^)(ARTErrorInfo *__art_nullable))callback;

- (__GENERIC(ARTEventListener, ARTMessage *) *__art_nullable)subscribe:(void (^)(ARTMessage *message))cb;
- (__GENERIC(ARTEventListener, ARTMessage *) *__art_nullable)subscribe:(void (^)(ARTMessage *message))callback;
- (__GENERIC(ARTEventListener, ARTMessage *) *__art_nullable)subscribeWithAttachCallback:(art_nullable void (^)(ARTErrorInfo *__art_nullable))onAttach callback:(void (^)(ARTMessage *message))cb;
- (__GENERIC(ARTEventListener, ARTMessage *) *__art_nullable)subscribe:(NSString *)name callback:(void (^)(ARTMessage *message))cb;
- (__GENERIC(ARTEventListener, ARTMessage *) *__art_nullable)subscribe:(NSString *)name onAttach:(art_nullable void (^)(ARTErrorInfo *__art_nullable))onAttach callback:(void (^)(ARTMessage *message))cb;
Expand Down
28 changes: 14 additions & 14 deletions Source/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ - (void)sendMessage:(ARTProtocolMessage *)pm callback:(void (^)(ARTStatus *))cb
}];
}

- (ARTPresenceMap *) presenceMap {
- (ARTPresenceMap *)presenceMap {
return _presenceMap;
}

Expand All @@ -188,8 +188,8 @@ - (void)throwOnDisconnectedOrFailed {
}
}

- (ARTEventListener<ARTMessage *> *)subscribe:(void (^)(ARTMessage * _Nonnull))cb {
return [self subscribeWithAttachCallback:nil callback:cb];
- (ARTEventListener<ARTMessage *> *)subscribe:(void (^)(ARTMessage * _Nonnull))callback {
return [self subscribeWithAttachCallback:nil callback:callback];
}

- (ARTEventListener<ARTMessage *> *)subscribeWithAttachCallback:(void (^)(ARTErrorInfo * _Nullable))onAttach callback:(void (^)(ARTMessage * _Nonnull))cb {
Expand Down Expand Up @@ -448,23 +448,23 @@ - (void)attach {
[self attach:nil];
}

- (void)attach:(void (^)(ARTErrorInfo * _Nullable))cb {
- (void)attach:(void (^)(ARTErrorInfo * _Nullable))callback {
switch (self.state) {
case ARTRealtimeChannelAttaching:
[self.realtime.logger debug:__FILE__ line:__LINE__ message:@"already attaching"];
if (cb) [_attachedEventEmitter once:cb];
if (callback) [_attachedEventEmitter once:callback];
return;
case ARTRealtimeChannelAttached:
[self.realtime.logger debug:__FILE__ line:__LINE__ message:@"already attached"];
if (cb) cb(nil);
if (callback) callback(nil);
return;
default:
break;
}

if (![self.realtime isActive]) {
[self.realtime.logger debug:__FILE__ line:__LINE__ message:@"can't attach when not in an active state"];
if (cb) cb([ARTErrorInfo createWithCode:90000 message:@"Can't attach when not in an active state"]);
if (callback) callback([ARTErrorInfo createWithCode:90000 message:@"Can't attach when not in an active state"]);
return;
}

Expand All @@ -475,7 +475,7 @@ - (void)attach:(void (^)(ARTErrorInfo * _Nullable))cb {
__block BOOL timeouted = false;

[self.realtime send:attachMessage callback:nil];
if (cb) [_attachedEventEmitter once:cb];
if (callback) [_attachedEventEmitter once:callback];
// Set state: Attaching
[self transition:ARTRealtimeChannelAttaching status:[ARTStatus state:ARTStateOk]];

Expand All @@ -489,27 +489,27 @@ - (void)attach:(void (^)(ARTErrorInfo * _Nullable))cb {
} interval:[ARTDefault realtimeRequestTimeout]];
}

- (void)detach:(void (^)(ARTErrorInfo * _Nullable))cb {
- (void)detach:(void (^)(ARTErrorInfo * _Nullable))callback {
switch (self.state) {
case ARTRealtimeChannelInitialized:
[self.realtime.logger debug:__FILE__ line:__LINE__ message:@"can't detach when not attached"];
if (cb) [_detachedEventEmitter once:cb];
if (callback) [_detachedEventEmitter once:callback];
return;
case ARTRealtimeChannelDetaching:
[self.realtime.logger debug:__FILE__ line:__LINE__ message:@"already detaching"];
if (cb) [_detachedEventEmitter once:cb];
if (callback) [_detachedEventEmitter once:callback];
return;
case ARTRealtimeChannelDetached:
[self.realtime.logger debug:__FILE__ line:__LINE__ message:@"already detached"];
if (cb) cb(nil);
if (callback) callback(nil);
return;
default:
break;
}

if (![self.realtime isActive]) {
[self.realtime.logger debug:__FILE__ line:__LINE__ message:@"can't detach when not in an active state"];
if (cb) cb([ARTErrorInfo createWithCode:90000 message:@"Can't detach when not in an active state"]);
if (callback) callback([ARTErrorInfo createWithCode:90000 message:@"Can't detach when not in an active state"]);
return;
}

Expand All @@ -520,7 +520,7 @@ - (void)detach:(void (^)(ARTErrorInfo * _Nullable))cb {
__block BOOL timeouted = false;

[self.realtime send:detachMessage callback:nil];
if (cb) [_detachedEventEmitter once:cb];
if (callback) [_detachedEventEmitter once:callback];
// Set state: Detaching
[self transition:ARTRealtimeChannelDetaching status:[ARTStatus state:ARTStateOk]];

Expand Down
2 changes: 1 addition & 1 deletion Source/ARTRealtimePresence.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ART_ASSUME_NONNULL_BEGIN
- (void)leaveClient:(NSString *)clientId data:(id __art_nullable)data;
- (void)leaveClient:(NSString *)clientId data:(id __art_nullable)data callback:(art_nullable void (^)(ARTErrorInfo *__art_nullable))cb;

- (__GENERIC(ARTEventListener, ARTPresenceMessage *) *)subscribe:(void (^)(ARTPresenceMessage *message))cb;
- (__GENERIC(ARTEventListener, ARTPresenceMessage *) *)subscribe:(void (^)(ARTPresenceMessage *message))callback;
- (__GENERIC(ARTEventListener, ARTPresenceMessage *) *)subscribe:(ARTPresenceAction)action callback:(void (^)(ARTPresenceMessage *message))cb;
- (void)unsubscribe;
- (void)unsubscribe:(__GENERIC(ARTEventListener, ARTPresenceMessage *) *)listener;
Expand Down
4 changes: 2 additions & 2 deletions Source/ARTRealtimePresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ - (BOOL)isSyncComplete {
return [[self channel].presenceMap isSyncComplete];
}

- (ARTEventListener<ARTPresenceMessage *> *)subscribe:(void (^)(ARTPresenceMessage * _Nonnull))cb {
- (ARTEventListener<ARTPresenceMessage *> *)subscribe:(void (^)(ARTPresenceMessage * _Nonnull))callback {
[[self channel] attach];
return [[self channel].presenceEventEmitter on:cb];
return [[self channel].presenceEventEmitter on:callback];
}

- (ARTEventListener<ARTPresenceMessage *> *)subscribe:(ARTPresenceAction)action callback:(void (^)(ARTPresenceMessage * _Nonnull))cb {
Expand Down

0 comments on commit c9b7b34

Please sign in to comment.