Skip to content

Commit f5b2078

Browse files
committed
chore: rename Cancellation to Subscription to avoid confusions with coroutine cancellation
1 parent 54ecb93 commit f5b2078

File tree

10 files changed

+29
-29
lines changed

10 files changed

+29
-29
lines changed

chat-android/src/main/java/com/ably/chat/Cancellation.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

chat-android/src/main/java/com/ably/chat/ConnectionStatus.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface ConnectionStatus {
2525
* Registers a listener that will be called whenever the connection status changes.
2626
* @param listener The function to call when the status changes.
2727
*/
28-
fun on(listener: Listener): Cancellation
28+
fun on(listener: Listener): Subscription
2929

3030
/**
3131
* An interface for listening to changes for the connection status

chat-android/src/main/java/com/ably/chat/EmitsDiscontinuities.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface EmitsDiscontinuities {
1010
* Register a listener to be called when a discontinuity is detected.
1111
* @param listener The listener to be called when a discontinuity is detected.
1212
*/
13-
fun onDiscontinuity(listener: Listener): Cancellation
13+
fun onDiscontinuity(listener: Listener): Subscription
1414

1515
/**
1616
* An interface for listening when discontinuity happens

chat-android/src/main/java/com/ably/chat/Messages.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ data class SendMessageParams(
169169
val headers: MessageHeaders? = null,
170170
)
171171

172-
interface MessagesSubscription : Cancellation {
172+
interface MessagesSubscription : Subscription {
173173
suspend fun getPreviousMessages(queryOptions: QueryOptions): PaginatedResult<Message>
174174
}
175175

@@ -195,7 +195,7 @@ class DefaultMessages(
195195

196196
override suspend fun send(params: SendMessageParams): Message = chatApi.sendMessage(roomId, params)
197197

198-
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
198+
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
199199
TODO("Not yet implemented")
200200
}
201201
}

chat-android/src/main/java/com/ably/chat/Occupancy.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface Occupancy : EmitsDiscontinuities {
2323
*
2424
* @param listener A listener to be called when the occupancy of the room changes.
2525
*/
26-
fun subscribe(listener: Listener): Cancellation
26+
fun subscribe(listener: Listener): Subscription
2727

2828
/**
2929
* Get the current occupancy of the chat room.
@@ -65,15 +65,15 @@ internal class DefaultOccupancy(
6565
override val channel: Channel
6666
get() = messages.channel
6767

68-
override fun subscribe(listener: Occupancy.Listener): Cancellation {
68+
override fun subscribe(listener: Occupancy.Listener): Subscription {
6969
TODO("Not yet implemented")
7070
}
7171

7272
override suspend fun get(): OccupancyEvent {
7373
TODO("Not yet implemented")
7474
}
7575

76-
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
76+
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
7777
TODO("Not yet implemented")
7878
}
7979
}

chat-android/src/main/java/com/ably/chat/Presence.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ interface Presence : EmitsDiscontinuities {
6060
* Subscribe the given listener to all presence events.
6161
* @param listener listener to subscribe
6262
*/
63-
fun subscribe(listener: Listener): Cancellation
63+
fun subscribe(listener: Listener): Subscription
6464

6565
/**
6666
* An interface for listening to new presence event
@@ -156,11 +156,11 @@ internal class DefaultPresence(
156156
TODO("Not yet implemented")
157157
}
158158

159-
override fun subscribe(listener: Presence.Listener): Cancellation {
159+
override fun subscribe(listener: Presence.Listener): Subscription {
160160
TODO("Not yet implemented")
161161
}
162162

163-
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
163+
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
164164
TODO("Not yet implemented")
165165
}
166166
}

chat-android/src/main/java/com/ably/chat/RoomReactions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface RoomReactions : EmitsDiscontinuities {
3838
* @param listener The listener function to be called when a reaction is received.
3939
* @returns A response object that allows you to control the subscription.
4040
*/
41-
fun subscribe(listener: Listener): Cancellation
41+
fun subscribe(listener: Listener): Subscription
4242

4343
/**
4444
* An interface for listening to new reaction events
@@ -111,11 +111,11 @@ internal class DefaultRoomReactions(
111111
TODO("Not yet implemented")
112112
}
113113

114-
override fun subscribe(listener: RoomReactions.Listener): Cancellation {
114+
override fun subscribe(listener: RoomReactions.Listener): Subscription {
115115
TODO("Not yet implemented")
116116
}
117117

118-
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
118+
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
119119
TODO("Not yet implemented")
120120
}
121121
}

chat-android/src/main/java/com/ably/chat/RoomStatus.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface RoomStatus {
2121
* @param listener The function to call when the status changes.
2222
* @returns An object that can be used to unregister the listener.
2323
*/
24-
fun on(listener: Listener): Cancellation
24+
fun on(listener: Listener): Subscription
2525

2626
/**
2727
* An interface for listening to changes for the room status
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.ably.chat
2+
3+
/**
4+
* An unsubscription handle, returned by various functions (mostly subscriptions)
5+
* where unsubscription is required.
6+
*/
7+
fun interface Subscription {
8+
/**
9+
* Handle unsubscription (unsubscribe listeners, clean up)
10+
*/
11+
fun unsubscribe()
12+
}

chat-android/src/main/java/com/ably/chat/Typing.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface Typing : EmitsDiscontinuities {
3737
*
3838
* @param listener A listener to be called when the typing state of a user in the room changes.
3939
*/
40-
fun subscribe(listener: Listener): Cancellation
40+
fun subscribe(listener: Listener): Subscription
4141

4242
/**
4343
* Get the current typers, a set of clientIds.
@@ -84,7 +84,7 @@ internal class DefaultTyping(
8484
override val channel: Channel
8585
get() = realtimeClient.channels.get(typingIndicatorsChannelName, ChatChannelOptions())
8686

87-
override fun subscribe(listener: Typing.Listener): Cancellation {
87+
override fun subscribe(listener: Typing.Listener): Subscription {
8888
TODO("Not yet implemented")
8989
}
9090

@@ -100,7 +100,7 @@ internal class DefaultTyping(
100100
TODO("Not yet implemented")
101101
}
102102

103-
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
103+
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
104104
TODO("Not yet implemented")
105105
}
106106
}

0 commit comments

Comments
 (0)