aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/API
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-04-14 17:19:06 -0700
committerGravatar GitHub <noreply@github.com>2018-04-14 17:19:06 -0700
commit33b12f6c70729d56c6e6350d435559cec1c44c61 (patch)
tree60d916bb7509f82e8950b887b45f9dd0bf80251a /Firestore/Source/API
parentfd84cd60aaf52cbe405ff8248665029827d56e97 (diff)
Replace `DocumentListenOptions` with a simple boolean. (#1099)
* Replace `DocumentListenOptions` with a simple boolean. Instead of calling `addSnapshotListener(options: DocumentListenOptions.includeMetadataChanges(true))` call `addSnapshotListener(includeMetadataChanges:true)` * Style
Diffstat (limited to 'Firestore/Source/API')
-rw-r--r--Firestore/Source/API/FIRDocumentReference.mm66
1 files changed, 15 insertions, 51 deletions
diff --git a/Firestore/Source/API/FIRDocumentReference.mm b/Firestore/Source/API/FIRDocumentReference.mm
index 9fb4541..d3a9295 100644
--- a/Firestore/Source/API/FIRDocumentReference.mm
+++ b/Firestore/Source/API/FIRDocumentReference.mm
@@ -52,40 +52,6 @@ using firebase::firestore::model::ResourcePath;
NS_ASSUME_NONNULL_BEGIN
-#pragma mark - FIRDocumentListenOptions
-
-@interface FIRDocumentListenOptions ()
-
-- (instancetype)initWithIncludeMetadataChanges:(BOOL)includeMetadataChanges
- NS_DESIGNATED_INITIALIZER;
-
-@property(nonatomic, assign, readonly) BOOL includeMetadataChanges;
-
-@end
-
-@implementation FIRDocumentListenOptions
-
-+ (instancetype)options {
- return [[FIRDocumentListenOptions alloc] init];
-}
-
-- (instancetype)initWithIncludeMetadataChanges:(BOOL)includeMetadataChanges {
- if (self = [super init]) {
- _includeMetadataChanges = includeMetadataChanges;
- }
- return self;
-}
-
-- (instancetype)init {
- return [self initWithIncludeMetadataChanges:NO];
-}
-
-- (instancetype)includeMetadataChanges:(BOOL)includeMetadataChanges {
- return [[FIRDocumentListenOptions alloc] initWithIncludeMetadataChanges:includeMetadataChanges];
-}
-
-@end
-
#pragma mark - FIRDocumentReference
@interface FIRDocumentReference ()
@@ -198,10 +164,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getDocumentWithCompletion:(void (^)(FIRDocumentSnapshot *_Nullable document,
NSError *_Nullable error))completion {
- FSTListenOptions *listenOptions =
- [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:YES
- includeDocumentMetadataChanges:YES
- waitForSyncWhenOnline:YES];
+ FSTListenOptions *options = [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:YES
+ includeDocumentMetadataChanges:YES
+ waitForSyncWhenOnline:YES];
dispatch_semaphore_t registered = dispatch_semaphore_create(0);
__block id<FIRListenerRegistration> listenerRegistration;
@@ -238,20 +203,20 @@ NS_ASSUME_NONNULL_BEGIN
}
};
- listenerRegistration =
- [self addSnapshotListenerInternalWithOptions:listenOptions listener:listener];
+ listenerRegistration = [self addSnapshotListenerInternalWithOptions:options listener:listener];
dispatch_semaphore_signal(registered);
}
- (id<FIRListenerRegistration>)addSnapshotListener:(FIRDocumentSnapshotBlock)listener {
- return [self addSnapshotListenerWithOptions:nil listener:listener];
+ return [self addSnapshotListenerWithIncludeMetadataChanges:NO listener:listener];
}
-- (id<FIRListenerRegistration>)addSnapshotListenerWithOptions:
- (nullable FIRDocumentListenOptions *)options
- listener:(FIRDocumentSnapshotBlock)listener {
- return [self addSnapshotListenerInternalWithOptions:[self internalOptions:options]
- listener:listener];
+- (id<FIRListenerRegistration>)
+addSnapshotListenerWithIncludeMetadataChanges:(BOOL)includeMetadataChanges
+ listener:(FIRDocumentSnapshotBlock)listener {
+ FSTListenOptions *options =
+ [self internalOptionsForIncludeMetadataChanges:includeMetadataChanges];
+ return [self addSnapshotListenerInternalWithOptions:options listener:listener];
}
- (id<FIRListenerRegistration>)
@@ -291,11 +256,10 @@ addSnapshotListenerInternalWithOptions:(FSTListenOptions *)internalOptions
}
/** Converts the public API options object to the internal options object. */
-- (FSTListenOptions *)internalOptions:(nullable FIRDocumentListenOptions *)options {
- return
- [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:options.includeMetadataChanges
- includeDocumentMetadataChanges:options.includeMetadataChanges
- waitForSyncWhenOnline:NO];
+- (FSTListenOptions *)internalOptionsForIncludeMetadataChanges:(BOOL)includeMetadataChanges {
+ return [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:includeMetadataChanges
+ includeDocumentMetadataChanges:includeMetadataChanges
+ waitForSyncWhenOnline:NO];
}
@end