Class DittoStoreObserver
- All Implemented Interfaces:
AutoCloseable
A store observer that monitors query results and invokes a handler when they change.
Store observers enable reactive data access by automatically notifying your application
when the results of a DQL query change. Create a store observer by calling
DittoStore.registerObserver(String, DittoCborSerializable.Dictionary, DittoChangeListener).
The store observer remains active until one of the following occurs:
- The [#close()] method is called
- The owning [Ditto] instance goes out of scope
This class implements AutoCloseable for resource management. Use try-with-resources
statements for automatic cleanup.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this store observer and stops monitoring for changes.boolean@Nullable DittoCborSerializable.DictionaryReturns the query arguments for this store observer.@NonNull StringgetQuery()Returns the DQL query string for this store observer.inthashCode()booleanisClosed()Returns whether this store observer is closed.
-
Method Details
-
getQuery
Returns the DQL query string for this store observer.
This is the same query string that was passed when registering the observer.
- Returns:
- the DQL query string.
-
getArguments
Returns the query arguments for this store observer.
These are the same query arguments that were passed when registering the observer. If no arguments were provided during registration, this method returns
null.- Returns:
- the query arguments as a
DittoCborSerializable.Dictionary, ornullif none were provided.
-
isClosed
public boolean isClosed()Returns whether this store observer is closed.
A store observer is considered closed if:
- Returns:
trueif the store observer is closed;falseotherwise.
-
close
Closes this store observer and stops monitoring for changes.
After calling this method, the handler that was registered with this store observer will no longer be invoked. This is a no-op if the store observer is already closed or the owning
Dittoinstance has gone out of scope.- Specified by:
closein interfaceAutoCloseable- Throws:
DittoException- if an error occurs during cleanup.
-
hashCode
-
equals
-