Skip to content

Commit f053c49

Browse files
committed
- Marked channel.object.get method non-blocking using completablefuture
- Replaced ObjectsSubscription import with Subscription as per requirement
1 parent bfb6de1 commit f053c49

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

lib/src/main/java/io/ably/lib/object/RealtimeObject.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import io.ably.lib.object.path.types.LiveMapPathObject;
44
import io.ably.lib.object.state.ObjectStateChange;
55
import io.ably.lib.object.state.ObjectStateEvent;
6-
import io.ably.lib.objects.ObjectsSubscription;
76
import io.ably.lib.types.AblyException;
87
import io.ably.lib.types.ErrorInfo;
9-
import org.jetbrains.annotations.Blocking;
108
import org.jetbrains.annotations.NotNull;
119

10+
import java.util.concurrent.CompletableFuture;
11+
1212
/**
1313
* The RealtimeObject interface is the entry point to the strongly-typed, path-based
1414
* LiveObjects API on a channel. It exposes the root of the objects graph as a
@@ -33,16 +33,17 @@ public interface RealtimeObject extends ObjectStateChange {
3333
* when working with multiple channels with different underlying data structures.
3434
*
3535
* <p>This operation requires the {@code OBJECT_SUBSCRIBE} channel mode. It implicitly
36-
* attaches the channel if it is not already attached, and waits for the objects
37-
* synchronization state to transition to {@code SYNCED} before returning.
36+
* attaches the channel if it is not already attached; the returned future completes once
37+
* the objects synchronization state has transitioned to {@code SYNCED}, and completes
38+
* exceptionally with an {@code AblyException} if synchronization fails.
3839
*
3940
* <p>Spec: RTO23, RTO23f (typed SDKs return a {@link LiveMapPathObject})
4041
*
41-
* @return the root {@link LiveMapPathObject} for this channel's objects graph.
42+
* @return a future that completes with the root {@link LiveMapPathObject} for this
43+
* channel's objects graph.
4244
*/
43-
@Blocking
4445
@NotNull
45-
LiveMapPathObject get();
46+
CompletableFuture<LiveMapPathObject> get();
4647

4748
/**
4849
* Null-Object guard for {@link RealtimeObject}, used as the value of {@code channel.object}
@@ -64,12 +65,12 @@ final class Unavailable implements RealtimeObject {
6465
private Unavailable() {}
6566

6667
@Override
67-
public @NotNull LiveMapPathObject get() {
68+
public @NotNull CompletableFuture<LiveMapPathObject> get() {
6869
throw missing();
6970
}
7071

7172
@Override
72-
public ObjectsSubscription on(@NotNull ObjectStateEvent event, ObjectStateChange.@NotNull Listener listener) {
73+
public Subscription on(@NotNull ObjectStateEvent event, ObjectStateChange.@NotNull Listener listener) {
7374
throw missing();
7475
}
7576

lib/src/main/java/io/ably/lib/object/state/ObjectStateChange.java

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

3-
import io.ably.lib.objects.ObjectsSubscription;
3+
import io.ably.lib.object.Subscription;
44
import org.jetbrains.annotations.NonBlocking;
55
import org.jetbrains.annotations.NotNull;
66

@@ -17,7 +17,7 @@ public interface ObjectStateChange {
1717
* @return a subscription object that can be used to unsubscribe from the event
1818
*/
1919
@NonBlocking
20-
ObjectsSubscription on(@NotNull ObjectStateEvent event, @NotNull ObjectStateChange.Listener listener);
20+
Subscription on(@NotNull ObjectStateEvent event, @NotNull ObjectStateChange.Listener listener);
2121

2222
/**
2323
* Unsubscribes the specified listener from all synchronization state events.

0 commit comments

Comments
 (0)