ditto-lib / live.ditto / DittoPendingIDSpecificOperation

DittoPendingIDSpecificOperation

class DittoPendingIDSpecificOperation

These objects are returned when using findByID functionality on DittoCollections. You can either call exec on the object to get an immediate return value, or you can establish either a live query or a subscription, which both work over time. A live query, established by calling observe, will notify you every time there's an update to the document with the ID you provided in the preceding findByID call. A subscription, established by calling subscribe, will act as a signal to other peers that you would like to receive updates from them about the document with the ID you provided in the preceding findByID call. Calling observe will generate both a subscription and a live query at the same time. If you'd like to only observe local changes then you can call observeLocal. Update and remove functionality is also exposed through this object. Update and remove functionality is also exposed through this object.

Properties

collectionName

the name of the collection that the operation will be performed on.

val collectionName: String

docID

the ID of the document that the operation will be performed on.

val docID: String

Functions

evict

Evict the document with the matching ID.

fun evict(): Boolean

exec

Execute the find operation to return the document with the matching ID.

fun exec(): DittoDocument?

observe

Enables you to listen for changes that occur in relation to a document. The eventHandler closure will be called when local or remote changes are made to the document referenced by the findByID call that precedes the call to observe. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided eventHandler to be called when an update occurs.

fun observe(eventHandler: (DittoDocument?, DittoSingleDocumentLiveQueryEvent) -> Unit): DittoLiveQuery

Enables you to listen for changes that occur in relation to a document. The callback parameter will be called when local or remote changes are made to the document referenced by the findByID call that precedes the call to observe. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided eventHandler to be called when an update occurs.

fun observe(callback: DittoSingleDocumentLiveQueryCallback): DittoLiveQuery

observeLocal

Enables you to listen for changes that occur in relation to a document. This won't subscribe to receive changes made remotely by others and so it will only fire updates when a local change is made. If you want to receive remotely performed updates as well then use observe or also call subscribe separately after another findByID call that references the same document ID. The returned DittoLiveQuery object must be kept in scope for as long as you want the provided eventHandler to be called when an update occurs.

fun observeLocal(eventHandler: (DittoDocument?, DittoSingleDocumentLiveQueryEvent) -> Unit): DittoLiveQuery
fun observeLocal(callback: DittoSingleDocumentLiveQueryCallback): DittoLiveQuery

remove

Remove the document with the matching ID.

fun remove(): Boolean

subscribe

Enables you to subscribe to changes that occur in relation to a document. Having a subscription acts as a signal to other peers that you are interested in receiving updates when local or remote changes are made to the relevant document. The returned DittoSubscription object must be kept in scope for as long as you want to keep receiving updates.

fun subscribe(): DittoSubscription

update

Update the document with the matching ID.

fun update(closure: (DittoMutableDocument?) -> Unit): List<DittoUpdateResult>
fun update(updater: DittoSingleMutableDocumentUpdater): List<DittoUpdateResult>