Skip to content

Commit

Permalink
chore: rename Cancellation to Subscription to avoid confusions wi…
Browse files Browse the repository at this point in the history
…th coroutine cancellation
  • Loading branch information
ttypic committed Sep 17, 2024
1 parent 54ecb93 commit f5b2078
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
12 changes: 0 additions & 12 deletions chat-android/src/main/java/com/ably/chat/Cancellation.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface ConnectionStatus {
* Registers a listener that will be called whenever the connection status changes.
* @param listener The function to call when the status changes.
*/
fun on(listener: Listener): Cancellation
fun on(listener: Listener): Subscription

/**
* An interface for listening to changes for the connection status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface EmitsDiscontinuities {
* Register a listener to be called when a discontinuity is detected.
* @param listener The listener to be called when a discontinuity is detected.
*/
fun onDiscontinuity(listener: Listener): Cancellation
fun onDiscontinuity(listener: Listener): Subscription

/**
* An interface for listening when discontinuity happens
Expand Down
4 changes: 2 additions & 2 deletions chat-android/src/main/java/com/ably/chat/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ data class SendMessageParams(
val headers: MessageHeaders? = null,
)

interface MessagesSubscription : Cancellation {
interface MessagesSubscription : Subscription {
suspend fun getPreviousMessages(queryOptions: QueryOptions): PaginatedResult<Message>
}

Expand All @@ -195,7 +195,7 @@ class DefaultMessages(

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

override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
TODO("Not yet implemented")
}
}
6 changes: 3 additions & 3 deletions chat-android/src/main/java/com/ably/chat/Occupancy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Occupancy : EmitsDiscontinuities {
*
* @param listener A listener to be called when the occupancy of the room changes.
*/
fun subscribe(listener: Listener): Cancellation
fun subscribe(listener: Listener): Subscription

/**
* Get the current occupancy of the chat room.
Expand Down Expand Up @@ -65,15 +65,15 @@ internal class DefaultOccupancy(
override val channel: Channel
get() = messages.channel

override fun subscribe(listener: Occupancy.Listener): Cancellation {
override fun subscribe(listener: Occupancy.Listener): Subscription {
TODO("Not yet implemented")
}

override suspend fun get(): OccupancyEvent {
TODO("Not yet implemented")
}

override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
TODO("Not yet implemented")
}
}
6 changes: 3 additions & 3 deletions chat-android/src/main/java/com/ably/chat/Presence.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface Presence : EmitsDiscontinuities {
* Subscribe the given listener to all presence events.
* @param listener listener to subscribe
*/
fun subscribe(listener: Listener): Cancellation
fun subscribe(listener: Listener): Subscription

/**
* An interface for listening to new presence event
Expand Down Expand Up @@ -156,11 +156,11 @@ internal class DefaultPresence(
TODO("Not yet implemented")
}

override fun subscribe(listener: Presence.Listener): Cancellation {
override fun subscribe(listener: Presence.Listener): Subscription {
TODO("Not yet implemented")
}

override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
TODO("Not yet implemented")
}
}
6 changes: 3 additions & 3 deletions chat-android/src/main/java/com/ably/chat/RoomReactions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface RoomReactions : EmitsDiscontinuities {
* @param listener The listener function to be called when a reaction is received.
* @returns A response object that allows you to control the subscription.
*/
fun subscribe(listener: Listener): Cancellation
fun subscribe(listener: Listener): Subscription

/**
* An interface for listening to new reaction events
Expand Down Expand Up @@ -111,11 +111,11 @@ internal class DefaultRoomReactions(
TODO("Not yet implemented")
}

override fun subscribe(listener: RoomReactions.Listener): Cancellation {
override fun subscribe(listener: RoomReactions.Listener): Subscription {
TODO("Not yet implemented")
}

override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
TODO("Not yet implemented")
}
}
2 changes: 1 addition & 1 deletion chat-android/src/main/java/com/ably/chat/RoomStatus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface RoomStatus {
* @param listener The function to call when the status changes.
* @returns An object that can be used to unregister the listener.
*/
fun on(listener: Listener): Cancellation
fun on(listener: Listener): Subscription

/**
* An interface for listening to changes for the room status
Expand Down
12 changes: 12 additions & 0 deletions chat-android/src/main/java/com/ably/chat/Subscription.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ably.chat

/**
* An unsubscription handle, returned by various functions (mostly subscriptions)
* where unsubscription is required.
*/
fun interface Subscription {
/**
* Handle unsubscription (unsubscribe listeners, clean up)
*/
fun unsubscribe()
}
6 changes: 3 additions & 3 deletions chat-android/src/main/java/com/ably/chat/Typing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Typing : EmitsDiscontinuities {
*
* @param listener A listener to be called when the typing state of a user in the room changes.
*/
fun subscribe(listener: Listener): Cancellation
fun subscribe(listener: Listener): Subscription

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

override fun subscribe(listener: Typing.Listener): Cancellation {
override fun subscribe(listener: Typing.Listener): Subscription {
TODO("Not yet implemented")
}

Expand All @@ -100,7 +100,7 @@ internal class DefaultTyping(
TODO("Not yet implemented")
}

override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Cancellation {
override fun onDiscontinuity(listener: EmitsDiscontinuities.Listener): Subscription {
TODO("Not yet implemented")
}
}

0 comments on commit f5b2078

Please sign in to comment.