diff options
Diffstat (limited to 'Firestore/Source/Public')
-rw-r--r-- | Firestore/Source/Public/FIRDocumentSnapshot.h | 49 | ||||
-rw-r--r-- | Firestore/Source/Public/FIRQuery.h | 51 | ||||
-rw-r--r-- | Firestore/Source/Public/FIRQuerySnapshot.h | 10 |
3 files changed, 30 insertions, 80 deletions
diff --git a/Firestore/Source/Public/FIRDocumentSnapshot.h b/Firestore/Source/Public/FIRDocumentSnapshot.h index 6e79a7f..669fe07 100644 --- a/Firestore/Source/Public/FIRDocumentSnapshot.h +++ b/Firestore/Source/Public/FIRDocumentSnapshot.h @@ -48,29 +48,6 @@ typedef NS_ENUM(NSInteger, FIRServerTimestampBehavior) { } NS_SWIFT_NAME(ServerTimestampBehavior); /** - * Options that configure how data is retrieved from a `DocumentSnapshot` - * (e.g. the desired behavior for server timestamps that have not yet been set - * to their final value). - */ -NS_SWIFT_NAME(SnapshotOptions) -@interface FIRSnapshotOptions : NSObject - -/** */ -- (instancetype)init __attribute__((unavailable("FIRSnapshotOptions cannot be created directly."))); - -/** - * If set, controls the return value for `FieldValue.serverTimestamp()` - * fields that have not yet been set to their final value. - * - * If omitted, `NSNull` will be returned by default. - * - * @return The created `FIRSnapshotOptions` object. - */ -+ (instancetype)serverTimestampBehavior:(FIRServerTimestampBehavior)serverTimestampBehavior; - -@end - -/** * A `FIRDocumentSnapshot` contains data read from a document in your Firestore database. The data * can be extracted with the `data` property or by using subscript syntax to access a specific * field. @@ -105,7 +82,7 @@ NS_SWIFT_NAME(DocumentSnapshot) * `NSNull`. You can use `dataWithOptions()` to configure this behavior. * * @return An `NSDictionary` containing all fields in the document or `nil` if the document doesn't - * exist. + * exist. */ - (nullable NSDictionary<NSString *, id> *)data; @@ -113,12 +90,13 @@ NS_SWIFT_NAME(DocumentSnapshot) * Retrieves all fields in the document as a `Dictionary`. Returns `nil` if the document doesn't * exist. * - * @param options `SnapshotOptions` to configure how data is returned from the snapshot (e.g. the - * desired behavior for server timestamps that have not yet been set to their final value). + * @param serverTimestampBehavior Configures how server timestamps that have not yet been set to + * their final value are returned from the snapshot. * @return A `Dictionary` containing all fields in the document or `nil` if the document doesn't - * exist. + * exist. */ -- (nullable NSDictionary<NSString *, id> *)dataWithOptions:(FIRSnapshotOptions *)options; +- (nullable NSDictionary<NSString *, id> *)dataWithServerTimestampBehavior: + (FIRServerTimestampBehavior)serverTimestampBehavior; /** * Retrieves a specific field from the document. Returns `nil` if the document or the field doesn't @@ -140,14 +118,14 @@ NS_SWIFT_NAME(DocumentSnapshot) * can use `get(_:options:)` to configure this behavior. * * @param field The field to retrieve. - * @param options `SnapshotOptions` to configure how data is returned from the snapshot (e.g. the - * desired behavior for server timestamps that have not yet been set to their final value). + * @param serverTimestampBehavior Configures how server timestamps that have not yet been set to + * their final value are returned from the snapshot. * @return The value contained in the field or `nil` if the document or field doesn't exist. */ // clang-format off - (nullable id)valueForField:(id)field - options:(FIRSnapshotOptions *)options - NS_SWIFT_NAME(get(_:options:)); + serverTimestampBehavior:(FIRServerTimestampBehavior)serverTimestampBehavior + NS_SWIFT_NAME(get(_:serverTimestampBehavior:)); // clang-format on /** @@ -190,11 +168,12 @@ NS_SWIFT_NAME(QueryDocumentSnapshot) /** * Retrieves all fields in the document as a `Dictionary`. * - * @param options `SnapshotOptions` to configure how data is returned from the snapshot (e.g. the - * desired behavior for server timestamps that have not yet been set to their final value). + * @param serverTimestampBehavior Configures how server timestamps that have not yet been set to + * their final value are returned from the snapshot. * @return A `Dictionary` containing all fields in the document. */ -- (NSDictionary<NSString *, id> *)dataWithOptions:(FIRSnapshotOptions *)options; +- (NSDictionary<NSString *, id> *)dataWithServerTimestampBehavior: + (FIRServerTimestampBehavior)serverTimestampBehavior; @end diff --git a/Firestore/Source/Public/FIRQuery.h b/Firestore/Source/Public/FIRQuery.h index ff15ac6..a28af39 100644 --- a/Firestore/Source/Public/FIRQuery.h +++ b/Firestore/Source/Public/FIRQuery.h @@ -25,46 +25,6 @@ NS_ASSUME_NONNULL_BEGIN -/** - * Options for use with `[FIRQuery addSnapshotListener]` to control the behavior of the snapshot - * listener. - */ -NS_SWIFT_NAME(QueryListenOptions) -@interface FIRQueryListenOptions : NSObject - -+ (instancetype)options NS_SWIFT_UNAVAILABLE("Use initializer"); - -- (instancetype)init; - -@property(nonatomic, assign, readonly) BOOL includeQueryMetadataChanges; - -/** - * Sets the includeQueryMetadataChanges option which controls whether metadata-only changes on the - * query (i.e. only `FIRQuerySnapshot.metadata` changed) should trigger snapshot events. Default is - * NO. - * - * @param includeQueryMetadataChanges Whether to raise events for metadata-only changes on the - * query. - * @return The receiver is returned for optional method chaining. - */ -- (instancetype)includeQueryMetadataChanges:(BOOL)includeQueryMetadataChanges - NS_SWIFT_NAME(includeQueryMetadataChanges(_:)); - -@property(nonatomic, assign, readonly) BOOL includeDocumentMetadataChanges; - -/** - * Sets the includeDocumentMetadataChanges option which controls whether document metadata-only - * changes (i.e. only `FIRDocumentSnapshot.metadata` on a document contained in the query - * changed) should trigger snapshot events. Default is NO. - * - * @param includeDocumentMetadataChanges Whether to raise events for document metadata-only changes. - * @return The receiver is returned for optional method chaining. - */ -- (instancetype)includeDocumentMetadataChanges:(BOOL)includeDocumentMetadataChanges - NS_SWIFT_NAME(includeDocumentMetadataChanges(_:)); - -@end - typedef void (^FIRQuerySnapshotBlock)(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error); @@ -103,16 +63,17 @@ NS_SWIFT_NAME(Query) /** * Attaches a listener for QuerySnapshot events. * - * @param options Options controlling the listener behavior. + * @param includeMetadataChanges Whether metadata-only changes (i.e. only + * `FIRDocumentSnapshot.metadata` changed) should trigger snapshot events. * @param listener The listener to attach. * * @return A FIRListenerRegistration that can be used to remove this listener. */ // clang-format off -- (id<FIRListenerRegistration>)addSnapshotListenerWithOptions: - (nullable FIRQueryListenOptions *)options - listener:(FIRQuerySnapshotBlock)listener - NS_SWIFT_NAME(addSnapshotListener(options:listener:)); +- (id<FIRListenerRegistration>) +addSnapshotListenerWithIncludeMetadataChanges:(BOOL)includeMetadataChanges + listener:(FIRQuerySnapshotBlock)listener + NS_SWIFT_NAME(addSnapshotListener(includeMetadataChanges:listener:)); // clang-format on #pragma mark - Filtering Data diff --git a/Firestore/Source/Public/FIRQuerySnapshot.h b/Firestore/Source/Public/FIRQuerySnapshot.h index 1266832..6a7e60d 100644 --- a/Firestore/Source/Public/FIRQuerySnapshot.h +++ b/Firestore/Source/Public/FIRQuerySnapshot.h @@ -58,6 +58,16 @@ NS_SWIFT_NAME(QuerySnapshot) */ @property(nonatomic, strong, readonly) NSArray<FIRDocumentChange *> *documentChanges; +/** + * Returns an array of the documents that changed since the last snapshot. If this is the first + * snapshot, all documents will be in the list as Added changes. + * + * @param includeMetadataChanges Whether metadata-only changes (i.e. only + * `FIRDocumentSnapshot.metadata` changed) should be included. + */ +- (NSArray<FIRDocumentChange *> *)documentChangesWithIncludeMetadataChanges: + (BOOL)includeMetadataChanges NS_SWIFT_NAME(documentChanges(includeMetadataChanges:)); + @end NS_ASSUME_NONNULL_END |