CBLLiveQuery

@interface CBLLiveQuery : NSObject

A CBLLiveQuery automatically observes database changes and re-run the query that the CBLLiveQuery object is created from. If there is a new query result or an error occurred, the CBLLiveQuery will report the changed result via the added listener blocks.

  • A CBLQueryParameters object used for setting values to the query parameters defined in the query. All parameters defined in the query must be given values before running the query, or the query will fail.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CBLQueryParameters *_Nonnull parameters;
  • Starts observing database changes and reports changes in the query result.

    Declaration

    Objective-C

    - (void)start;
  • Stops observing database changes.

    Declaration

    Objective-C

    - (void)stop;
  • Returns a string describing the implementation of the compiled query. This is intended to be read by a developer for purposes of optimizing the query, especially to add database indexes. It’s not machine-readable and its format may change.

    Declaration

    Objective-C

    - (nullable NSString *)explain:(NSError *_Nullable *_Nullable)error;

    Parameters

    error

    On return, the error if any.

    Return Value

    The compiled query explanation.

  • Adds a query change listener block.

    Declaration

    Objective-C

    - (nonnull id<NSObject>)addChangeListener:
        (nonnull void (^)(CBLLiveQueryChange *_Nonnull))block;

    Parameters

    block

    The block to be executed when the change is received.

    Return Value

    An opaque object to act as the listener and for removing the listener when calling the -removeChangeListener: method.

  • Removes a change listener. The given change listener is the opaque object returned by the -addChangeListener: method.

    Declaration

    Objective-C

    - (void)removeChangeListener:(nonnull id<NSObject>)listener;

    Parameters

    listener

    The listener object to be removed.