DittoPendingIDSpecificOperation
public 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.
-
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
DittoSubscriptionobject must be kept in scope for as long as you want to keep receiving updates.Declaration
Swift
public func subscribe() -> DittoSubscriptionReturn Value
A
DittoSubscriptionobject that must be kept in scope for as long as you want to keep receiving updates for documents that match the query specified in the preceding chain. -
Remove the document with the matching ID.
Declaration
Swift
@discardableResult public func remove() -> BoolReturn Value
trueif the document was found and removed.falseif the document wasn’t found and therefore wasn’t removed. -
Evict the document with the matching ID.
Declaration
Swift
@discardableResult public func evict() -> BoolReturn Value
trueif the document was found and evicted.falseif the document wasn’t found and therefore wasn’t evicted. -
Execute the find operation to return the document with the matching ID.
Declaration
Swift
public func exec() -> DittoDocument?Return Value
The
DittoDocumentwith the ID provided in thefindByIDcall ornilif the document was not found. -
Enables you to listen for changes that occur in relation to a document. The
eventHandlerclosure will be called when local or remote changes are made to the document referenced by thefindByIDcall that precedes the call toobserve. The returnedDittoLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Swift
public func observe( deliverOn queue: DispatchQueue = .main, eventHandler: @escaping (DittoDocument?, DittoSingleDocumentLiveQueryEvent) -> Void ) -> DittoLiveQueryParameters
queueThe
DispatchQueuethat will be used to deliver live query updates. Defaults toDispatchQueue.main.eventHandlerA closure that will be called every time there is a transaction committed to the store that involves a modification to the document with the relevant ID in the collection that
observewas called on.Return Value
A
DittoLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to listen for changes that occur in relation to a document, and to signal when you are ready for the live query to deliver the next event. The
eventHandlerclosure will be called when local or remote changes are made to the document referenced by thefindByIDcall that precedes the call toobserve. The returnedDittoLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Swift
public func observeWithNextSignal( deliverOn queue: DispatchQueue = .main, eventHandler: @escaping (DittoDocument?, DittoSingleDocumentLiveQueryEvent, @escaping DittoSignalNext) -> Void ) -> DittoLiveQueryParameters
queueThe
DispatchQueuethat will be used to deliver live query updates. Defaults toDispatchQueue.main.eventHandlerA closure that will be called every time there is a transaction committed to the store that involves a modification to the document with the relevant ID in the collection that
observewas called on.Return Value
A
DittoLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
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
observeor also callsubscribeseparately after anotherfindByIDcall that references the same document ID. The returnedDittoLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Swift
public func observeLocal( deliverOn queue: DispatchQueue = .main, eventHandler: @escaping (DittoDocument?, DittoSingleDocumentLiveQueryEvent) -> Void ) -> DittoLiveQueryParameters
queueThe
DispatchQueuethat will be used to deliver live query updates. Defaults toDispatchQueue.main.eventHandlerA closure that will be called every time there is a transaction committed to the store that involves a modification to the document with the relevant ID in the collection that
observeLocalwas called on.Return Value
A
DittoLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to listen for changes that occur in relation to a document, and to signal when you are ready for the live query to deliver the next event. 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
observeor also callsubscribeseparately after anotherfindByIDcall that references the same document ID. The returnedDittoLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Swift
public func observeLocalWithNextSignal( deliverOn queue: DispatchQueue = .main, eventHandler: @escaping (DittoDocument?, DittoSingleDocumentLiveQueryEvent, @escaping DittoSignalNext) -> Void ) -> DittoLiveQueryParameters
queueThe
DispatchQueuethat will be used to deliver live query updates. Defaults toDispatchQueue.main.eventHandlerA closure that will be called every time there is a transaction committed to the store that involves a modification to the document with the relevant ID in the collection that
observeLocalwas called on.Return Value
A
DittoLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Update the document with the matching ID.
Declaration
Swift
@discardableResult public func update( _ closure: @escaping (DittoMutableDocument?) -> Void ) -> [DittoUpdateResult]Parameters
closureA closure that gets called with the document matching the ID. If found, the document is a
DittoMutableDocument, so you can call update-related functions on it. If the document is not found then the value provided to the closure will benil.Return Value
A list of
DittoUpdateResults that describes the updates that were performed on the document. -
Update the document with the matching ID.
Throws
DittoSwiftError.Declaration
Swift
public func update<T>(using newValue: T) throws where T : Decodable, T : EncodableParameters
usingAn object representing the desired new state of the document’s value.
-
Undocumented
Declaration
Swift
typealias Snapshot = (document: DittoDocument?, event: DittoSingleDocumentLiveQueryEvent) -
A Combine publisher that produces a document matching the requested ID, if it can be found.
See moreDeclaration
Swift
struct SingleDocumentLiveQueryPublisher : Publisher -
A Combine publisher that produces a document matching the requested ID, if it can be found.
Declaration
Swift
func singleDocumentLiveQueryPublisher() -> SingleDocumentLiveQueryPublisherReturn Value
A
SingleDocumentLiveQueryPublisherwhich has an output of(DittoDocument?, DittoSingleDocumentLiveQueryEvent)
DittoPendingIDSpecificOperation Class Reference