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

Remove nullability of -subscribe* return value #2004

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Source/ARTRealtimeChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,19 @@ - (void)detach:(nullable ARTCallback)callback {
[_internal detach:callback];
}

- (ARTEventListener *_Nullable)subscribe:(ARTMessageCallback)callback {
- (ARTEventListener *)subscribe:(ARTMessageCallback)callback {
return [_internal subscribe:callback];
}

- (ARTEventListener *_Nullable)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)cb {
- (ARTEventListener *)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)cb {
return [_internal subscribeWithAttachCallback:onAttach callback:cb];
}

- (ARTEventListener *_Nullable)subscribe:(NSString *)name callback:(ARTMessageCallback)cb {
- (ARTEventListener *)subscribe:(NSString *)name callback:(ARTMessageCallback)cb {
return [_internal subscribe:name callback:cb];
}

- (ARTEventListener *_Nullable)subscribe:(NSString *)name onAttach:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)cb {
- (ARTEventListener *)subscribe:(NSString *)name onAttach:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)cb {
return [_internal subscribe:name onAttach:onAttach callback:cb];
}

Expand Down
8 changes: 4 additions & 4 deletions Source/ARTRealtimePresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ - (void)leaveClient:(NSString *)clientId data:(id _Nullable)data callback:(nulla
[_internal leaveClient:clientId data:data callback:cb];
}

- (ARTEventListener *_Nullable)subscribe:(ARTPresenceMessageCallback)callback {
- (ARTEventListener *)subscribe:(ARTPresenceMessageCallback)callback {
return [_internal subscribe:callback];
}

- (ARTEventListener *_Nullable)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)cb {
- (ARTEventListener *)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)cb {
return [_internal subscribeWithAttachCallback:onAttach callback:cb];
}

- (ARTEventListener *_Nullable)subscribe:(ARTPresenceAction)action callback:(ARTPresenceMessageCallback)cb {
- (ARTEventListener *)subscribe:(ARTPresenceAction)action callback:(ARTPresenceMessageCallback)cb {
return [_internal subscribe:action callback:cb];
}

- (ARTEventListener *_Nullable)subscribe:(ARTPresenceAction)action onAttach:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)cb {
- (ARTEventListener *)subscribe:(ARTPresenceAction)action onAttach:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)cb {
return [_internal subscribe:action onAttach:onAttach callback:cb];
}

Expand Down
8 changes: 4 additions & 4 deletions Source/include/Ably/ARTRealtimeChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @see See `subscribeWithAttachCallback:` for more details.
*/
- (ARTEventListener *_Nullable)subscribe:(ARTMessageCallback)callback;
- (ARTEventListener *)subscribe:(ARTMessageCallback)callback;

/**
* Registers a listener for messages on this channel. The caller supplies a listener function, which is called each time one or more messages arrives on the channel.
Expand All @@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An `ARTEventListener` object.
*/
- (ARTEventListener *_Nullable)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)callback;
- (ARTEventListener *)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)callback;

/**
* Registers a listener for messages with a given event `name` on this channel. The caller supplies a listener function, which is called each time one or more matching messages arrives on the channel.
Expand All @@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @see See `subscribeWithAttachCallback:` for more details.
*/
- (ARTEventListener *_Nullable)subscribe:(NSString *)name callback:(ARTMessageCallback)callback;
- (ARTEventListener *)subscribe:(NSString *)name callback:(ARTMessageCallback)callback;

/**
* Registers a listener for messages with a given event `name` on this channel. The caller supplies a listener function, which is called each time one or more matching messages arrives on the channel. A callback may optionally be passed in to this call to be notified of success or failure of the channel `-[ARTRealtimeChannelProtocol attach]` operation. It will not be called if the `ARTRealtimeChannelOptions.attachOnSubscribe` channel option is set to `false`.
Expand All @@ -109,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An `ARTEventListener` object.
*/
- (ARTEventListener *_Nullable)subscribe:(NSString *)name onAttach:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)callback;
- (ARTEventListener *)subscribe:(NSString *)name onAttach:(nullable ARTCallback)onAttach callback:(ARTMessageCallback)callback;

/**
* Deregisters all listeners to messages on this channel. This removes all earlier subscriptions.
Expand Down
8 changes: 4 additions & 4 deletions Source/include/Ably/ARTRealtimePresence.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An event listener object.
*/
- (ARTEventListener *_Nullable)subscribe:(ARTPresenceMessageCallback)callback;
- (ARTEventListener *)subscribe:(ARTPresenceMessageCallback)callback;

/**
* Registers a listener that is called each time a `ARTPresenceMessage` is received on the channel, such as a new member entering the presence set. A callback may optionally be passed in to this call to be notified of success or failure of the channel `-[ARTRealtimeChannelProtocol attach]` operation. It will not be called if the `ARTRealtimeChannelOptions.attachOnSubscribe` channel option is set to `false`.
Expand All @@ -152,7 +152,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An event listener object.
*/
- (ARTEventListener *_Nullable)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)callback;
- (ARTEventListener *)subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)callback;

/**
* Registers a listener that is called each time a `ARTPresenceMessage` matching a given `ARTPresenceAction` is received on the channel, such as a new member entering the presence set.
Expand All @@ -162,7 +162,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An event listener object.
*/
- (ARTEventListener *_Nullable)subscribe:(ARTPresenceAction)action callback:(ARTPresenceMessageCallback)callback;
- (ARTEventListener *)subscribe:(ARTPresenceAction)action callback:(ARTPresenceMessageCallback)callback;

/**
* Registers a listener that is called each time a `ARTPresenceMessage` matching a given `ARTPresenceAction` is received on the channel, such as a new member entering the presence set. A callback may optionally be passed in to this call to be notified of success or failure of the channel `-[ARTRealtimeChannelProtocol attach]` operation. It will not be called if the `ARTRealtimeChannelOptions.attachOnSubscribe` channel option is set to `false`.
Expand All @@ -173,7 +173,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An event listener object.
*/
- (ARTEventListener *_Nullable)subscribe:(ARTPresenceAction)action onAttach:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)callback;
- (ARTEventListener *)subscribe:(ARTPresenceAction)action onAttach:(nullable ARTCallback)onAttach callback:(ARTPresenceMessageCallback)callback;

/**
* Deregisters all listeners currently receiving `ARTPresenceMessage` for the channel.
Expand Down
4 changes: 2 additions & 2 deletions Test/Tests/RealtimeClientPresenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class RealtimeClientPresenceTests: XCTestCase {
defer { client.dispose(); client.close() }
let channel = client.channels.get(test.uniqueChannelName())

let listener = channel.presence.subscribe { _ in }!
let listener = channel.presence.subscribe { _ in }
XCTAssertEqual(channel.internal.internalPresence.eventEmitter.anyListeners.count, 1)
channel.presence.unsubscribe(listener)
XCTAssertEqual(channel.internal.internalPresence.eventEmitter.anyListeners.count, 0)
Expand Down Expand Up @@ -878,7 +878,7 @@ class RealtimeClientPresenceTests: XCTestCase {
defer { client.dispose(); client.close() }
let channel = client.channels.get(test.uniqueChannelName())

let listener = channel.presence.subscribe(.present) { _ in }!
let listener = channel.presence.subscribe(.present) { _ in }
XCTAssertEqual(channel.internal.internalPresence.eventEmitter.listeners.count, 1)
channel.presence.unsubscribe(.present, listener: listener)
XCTAssertEqual(channel.internal.internalPresence.eventEmitter.listeners.count, 0)
Expand Down
Loading