Class RealtimeObject.Unavailable
- All Implemented Interfaces:
-
RealtimeObject,ObjectStateChange
- Enclosing interface:
- RealtimeObject
RealtimeObject, used as the value of channel.object
when the LiveObjects plugin is not installed.
Because channel.object is a field, dereferencing it can never throw; instead
every method here fails fast with the plugin-missing error, so get(), on(),
off() and offAll() surface a clear, consistent error rather than a
NullPointerException.
A stateless singleton (INSTANCE) shared across all channels that lack the
plugin. Adding a method to RealtimeObject will fail compilation here until it is
guarded, which is the intended safety net.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.ably.lib.liveobjects.state.ObjectStateChange
ObjectStateChange.ListenerNested classes/interfaces inherited from interface io.ably.lib.liveobjects.RealtimeObject
RealtimeObject.Unavailable -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription@NotNull CompletableFuture<LiveMapPathObject>get()Retrieves aLiveMapPathObjectrooted at the channel's rootLiveMap.voidoff(@NotNull ObjectStateChange.Listener listener) Unsubscribes the specified listener from all synchronization state events.voidoffAll()Unsubscribes all listeners from all synchronization state events.on(@NotNull ObjectStateEvent event, @NotNull ObjectStateChange.Listener listener) Subscribes to a specific Objects synchronization state event.
-
Field Details
-
INSTANCE
-
-
Method Details
-
get
Description copied from interface:RealtimeObjectRetrieves aLiveMapPathObjectrooted at the channel's rootLiveMap. The returned object has an empty path and resolves to the rootLiveMap; use its navigation methods to address nested values within the objects graph.When called without a type variable, we return a default root type which is based on the globally defined interface for the Objects feature. A user can provide an explicit type to set the type structure on this particular channel. This is useful when working with multiple channels with different underlying data structures.
This operation requires the
OBJECT_SUBSCRIBEchannel mode. It implicitly attaches the channel if it is not already attached; the returned future completes once the objects synchronization state has transitioned toSYNCED, and completes exceptionally with anAblyExceptionif synchronization fails.Spec: RTO23, RTO23f (typed SDKs return a
LiveMapPathObject)- Specified by:
-
getin interfaceRealtimeObject - Returns:
- a future that completes with the root
LiveMapPathObjectfor this channel's objects graph.
-
on
public Subscription on(@NotNull @NotNull ObjectStateEvent event, @NotNull ObjectStateChange.Listener listener) Description copied from interface:ObjectStateChangeSubscribes to a specific Objects synchronization state event.This method registers the provided listener to be notified when the specified synchronization state event occurs. The returned subscription can be used to unsubscribe later when the notifications are no longer needed.
- Specified by:
-
onin interfaceObjectStateChange - Parameters:
-
event- the synchronization state event to subscribe to (SYNCING or SYNCED) -
listener- the listener that will be called when the event occurs - Returns:
- a subscription object that can be used to unsubscribe from the event
-
off
Description copied from interface:ObjectStateChangeUnsubscribes the specified listener from all synchronization state events.After calling this method, the provided listener will no longer receive any synchronization state event notifications.
- Specified by:
-
offin interfaceObjectStateChange - Parameters:
-
listener- the listener to unregister from all events
-
offAll
public void offAll()Description copied from interface:ObjectStateChangeUnsubscribes all listeners from all synchronization state events.After calling this method, no listeners will receive any synchronization state event notifications until new listeners are registered.
- Specified by:
-
offAllin interfaceObjectStateChange
-