LiveQuery
public class LiveQuery
A LiveQuery automatically observes database changes and re-run the query that the LiveQuery object is created from. If there is a new query result or an error occurred, the LiveQuery object will report the changed result via the added listener blocks.
-
Returns the Parameters 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
Swift
public var parameters: Parameters
-
Starts observing database changes and reports changes in the query result.
Declaration
Swift
public func start()
-
Stops observing database changes.
Declaration
Swift
public func 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.
Throws
An error if the query is invalid.Declaration
Swift
public func explain() throws -> String
Return Value
The implementation detail of the compiled query.
-
Adds a query change listener block.
Declaration
Swift
public func addChangeListener(_ block: @escaping (LiveQueryChange) -> Void) -> NSObjectProtocol
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
Swift
public func removeChangeListener(_ listener: NSObjectProtocol)
Parameters
listener
The listener object to be removed.