Skip to content

Commit 1bacaf5

Browse files
committed
[ECO-5457] Refactored ObjectsStateSubscription to ObjectsSubscription
- Updated usage doc for the same
1 parent 33ff9e2 commit 1bacaf5

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

lib/src/main/java/io/ably/lib/objects/state/ObjectsStateSubscription.java renamed to lib/src/main/java/io/ably/lib/objects/ObjectsSubscription.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
package io.ably.lib.objects.state;
1+
package io.ably.lib.objects;
22

33
/**
4-
* Represents a subscription that can be unsubscribed from.
5-
* This interface provides a way to clean up and remove subscriptions when they
6-
* are no longer needed.
4+
* Represents a objects subscription that can be unsubscribed from.
5+
* This interface provides a way to clean up and remove subscriptions when they are no longer needed.
76
* Example usage:
8-
* ```java
9-
* ObjectsStateSubscription s = objects.subscribe(ObjectsStateEvent.SYNCING, new ObjectsStateListener() {});
7+
* <pre>
8+
* {@code
9+
* ObjectsSubscription s = objects.subscribe(ObjectsStateEvent.SYNCING, new ObjectsStateListener() {});
1010
* // Later when done with the subscription
1111
* s.unsubscribe();
12+
* }
13+
* </pre>
1214
*/
13-
public interface ObjectsStateSubscription {
15+
public interface ObjectsSubscription {
1416
/**
1517
* This method should be called when the subscription is no longer needed,
1618
* it will make sure no further events will be sent to the subscriber and

lib/src/main/java/io/ably/lib/objects/state/ObjectsStateChange.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.ably.lib.objects.state;
22

3+
import io.ably.lib.objects.ObjectsSubscription;
34
import org.jetbrains.annotations.NonBlocking;
45
import org.jetbrains.annotations.NotNull;
56

@@ -16,7 +17,7 @@ public interface ObjectsStateChange {
1617
* @return a subscription object that can be used to unsubscribe from the event
1718
*/
1819
@NonBlocking
19-
ObjectsStateSubscription on(@NotNull ObjectsStateEvent event, @NotNull ObjectsStateChange.Listener listener);
20+
ObjectsSubscription on(@NotNull ObjectsStateEvent event, @NotNull ObjectsStateChange.Listener listener);
2021

2122
/**
2223
* Unsubscribes the specified listener from all synchronization state events.

live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.ably.lib.objects
22

33
import io.ably.lib.objects.state.ObjectsStateChange
44
import io.ably.lib.objects.state.ObjectsStateEvent
5-
import io.ably.lib.objects.state.ObjectsStateSubscription
65
import io.ably.lib.realtime.ChannelState
76
import io.ably.lib.types.Callback
87
import io.ably.lib.types.ProtocolMessage
@@ -90,7 +89,7 @@ internal class DefaultLiveObjects(private val channelName: String, internal val
9089
TODO("Not yet implemented")
9190
}
9291

93-
override fun on(event: ObjectsStateEvent, listener: ObjectsStateChange.Listener): ObjectsStateSubscription =
92+
override fun on(event: ObjectsStateEvent, listener: ObjectsStateChange.Listener): ObjectsSubscription =
9493
objectsManager.on(event, listener)
9594

9695
override fun off(listener: ObjectsStateChange.Listener) = objectsManager.off(listener)

live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsState.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.ably.lib.objects
22

33
import io.ably.lib.objects.state.ObjectsStateChange
44
import io.ably.lib.objects.state.ObjectsStateEvent
5-
import io.ably.lib.objects.state.ObjectsStateSubscription
65
import io.ably.lib.util.EventEmitter
76
import io.ably.lib.util.Log
87
import kotlinx.coroutines.*
@@ -66,9 +65,9 @@ internal abstract class ObjectsStateCoordinator : ObjectsStateChange, HandlesObj
6665

6766
private val emitterScope = CoroutineScope(Dispatchers.Default.limitedParallelism(1) + SupervisorJob())
6867

69-
override fun on(event: ObjectsStateEvent, listener: ObjectsStateChange.Listener): ObjectsStateSubscription {
68+
override fun on(event: ObjectsStateEvent, listener: ObjectsStateChange.Listener): ObjectsSubscription {
7069
externalObjectStateEmitter.on(event, listener)
71-
return ObjectsStateSubscription {
70+
return ObjectsSubscription {
7271
externalObjectStateEmitter.off(event, listener)
7372
}
7473
}

0 commit comments

Comments
 (0)