DITPendingCollectionsOperation
@interface DITPendingCollectionsOperation : NSObject
These objects are returned when calling collections on DITStore.
They allow chaining of further collections-related functions. You can either call exec on the
object to get an array of DITCollections as 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 a change in the
collections that the device knows about.
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 collections that they know about.
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.
If you want to observe changes in such a way that you can signal when you’re ready for the live
query to deliver a new update then you can call observeWithNextSignal or
observeLocalWithNextSignal.
-
Limit the number of collections that get returned.
Declaration
Objective-C
- (nonnull DITPendingCollectionsOperation *)limit:(int)limit;Parameters
limitThe maximum number of collections that will be returned.
Return Value
A
DITPendingCollectionsOperationthat you can chain further function calls to. -
Offset the resulting set of collections.
This is useful if you aren’t interested in the first N collections for one reason or another. For example, you might already have obtained the first 20 collections and so you might want to get the next 20 collections, and that is when you would use
offset.Declaration
Objective-C
- (nonnull DITPendingCollectionsOperation *)offset:(uint)offset;Parameters
offsetThe number of collections that you want the eventual resulting set of collections to be offset by (and thus not include).
Return Value
A
DITPendingCollectionsOperationthat you can chain further function calls to. -
Sort the collections based on a property of the collection.
Declaration
Objective-C
- (nonnull DITPendingCollectionsOperation *)sort:(nonnull NSString *)query direction:(DITSortDirection)direction;Parameters
queryThe query specifies the logic to be used when sorting the collections.
directionSpecify whether you want the sorting order to be ascending or descending.
Return Value
A
DITPendingCollectionsOperationthat you can chain further function calls to. -
Return the list of collections requested based on the preceding function chaining.
Declaration
Objective-C
- (nonnull NSArray<DITCollection *> *)exec;Return Value
A list of
DITCollectionss based on the preceding function chaining. -
Subscribes the device to updates about collections that other devices know about.
The returned
DITSubscriptionobject must be kept in scope for as long as you want to keep receiving updates.Declaration
Objective-C
- (nonnull DITSubscription *)subscribe;Return Value
A
DITSubscriptionobject that must be kept in scope for as long as you want to keep receiving updates from other devices about the collections that they know about. -
Enables you to subscribe to updates about collections that other devices know about, and have a block called when an update is received either locally or remotely.
The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *)observe: (nonnull void (^)(DITCollectionsEvent *_Nonnull))eventHandler;Parameters
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to subscribe to updates about collections that other devices know about, and have a block called when an update is received either locally or remotely.
The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *) observeWithDeliveryQueue:(nonnull dispatch_queue_t)dispatchQueue eventHandler:(nonnull void (^)(DITCollectionsEvent *_Nonnull)) eventHandler;Parameters
dispatchQueueThe dispatch queue that will be used to deliver updates. Defaults to the main queue.
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to subscribe to updates about collections that other devices know about, and have a block called when an update is received either locally or remotely. You wont receive any further callbacks until you explicitly signal that you are ready for the next event to be delivered.
This is a power-user API. If you’re unsure about which to use, you should probably default to using the simpler
observe:API.The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *)observeWithNextSignal: (nonnull void (^)(DITCollectionsEvent *_Nonnull, DittoSignalNextBlock _Nonnull))eventHandler;Parameters
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to subscribe to updates about collections that other devices know about, and have a block called when an update is received either locally or remotely. You wont receive any further callbacks until you explicitly signal that you are ready for the next event to be delivered.
This is a power-user API. If you’re unsure about which to use, you should probably default to using the simpler
observe:API.The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *) observeWithNextSignalAndDeliveryQueue: (nonnull dispatch_queue_t)dispatchQueue eventHandler:(nonnull void (^)( DITCollectionsEvent *_Nonnull, DittoSignalNextBlock _Nonnull)) eventHandler;Parameters
dispatchQueueThe dispatch queue that will be used to deliver live query updates. Defaults to the main queue.
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to subscribe to updates about collections local to this device.
This won’t subscribe to receive updates from other devices and so it will only fire when a local change to the known collections occurs. If you want to receive remote updates as well then use
observeor callsubscribe.The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *)observeLocal: (nonnull void (^)(DITCollectionsEvent *_Nonnull))eventHandler;Parameters
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to subscribe to updates about collections local to this device.
This won’t subscribe to receive updates from other devices and so it will only fire when a local change to the known collections occurs. If you want to receive remote updates as well then use
observeor callsubscribe.The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *) observeLocalWithDeliveryQueue:(nonnull dispatch_queue_t)dispatchQueue eventHandler: (nonnull void (^)(DITCollectionsEvent *_Nonnull)) eventHandler;Parameters
dispatchQueueThe dispatch queue that will be used to deliver live query updates. Defaults to the main queue.
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to subscribe to updates about collections local to this device.
This won’t subscribe to receive updates from other devices and so it will only fire when a local change to the known collections occurs. If you want to receive remote updates as well then use
observeor callsubscribe.You wont receive any further callbacks until you explicitly signal that you are ready for the next event to be delivered.
This is a power-user API. If you’re unsure about which to use, you should probably default to using the simpler
observe:API.The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *)observeLocalWithNextSignal: (nonnull void (^)(DITCollectionsEvent *_Nonnull, DittoSignalNextBlock _Nonnull))eventHandler;Parameters
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates. -
Enables you to subscribe to updates about collections local to this device.
This won’t subscribe to receive updates from other devices and so it will only fire when a local change to the known collections occurs. If you want to receive remote updates as well then use
observeor callsubscribe.You wont receive any further callbacks until you explicitly signal that you are ready for the next event to be delivered.
This is a power-user API. If you’re unsure about which to use, you should probably default to using the simpler
observe:API.The returned
DITLiveQueryobject must be kept in scope for as long as you want the providedeventHandlerto be called when an update occurs.Declaration
Objective-C
- (nonnull DITLiveQuery *) observeLocalWithNextSignalAndDeliveryQueue: (nonnull dispatch_queue_t)dispatchQueue eventHandler: (nonnull void (^)( DITCollectionsEvent *_Nonnull, DittoSignalNextBlock _Nonnull)) eventHandler;Parameters
dispatchQueueThe dispatch queue that will be used to deliver live query updates. Defaults to the main queue.
eventHandlerA block that will be called every time there is an update about the list of known about collections.
Return Value
A
DITLiveQueryobject that must be kept in scope for as long as you want to keep receiving updates.
DITPendingCollectionsOperation Class Reference