Files
firebase-ios-sdk/FirebaseDatabase/Sources/Core/View/FKeepSyncedEventRegistration.m
T

70 lines
2.2 KiB
Objective-C
Raw Normal View History

2017-05-15 12:27:07 -07:00
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2020-06-22 07:58:52 -07:00
#import "FirebaseDatabase/Sources/Core/View/FKeepSyncedEventRegistration.h"
2017-05-15 12:27:07 -07:00
@interface FKeepSyncedEventRegistration ()
@end
@implementation FKeepSyncedEventRegistration
+ (FKeepSyncedEventRegistration *)instance {
static dispatch_once_t onceToken;
static FKeepSyncedEventRegistration *keepSynced;
dispatch_once(&onceToken, ^{
2019-08-05 13:27:47 -07:00
keepSynced = [[FKeepSyncedEventRegistration alloc] init];
2017-05-15 12:27:07 -07:00
});
return keepSynced;
}
2019-08-05 13:27:47 -07:00
- (BOOL)responseTo:(FIRDataEventType)eventType {
2017-05-15 12:27:07 -07:00
return NO;
}
2019-08-05 13:27:47 -07:00
- (FDataEvent *)createEventFrom:(FChange *)change query:(FQuerySpec *)query {
[NSException
raise:NSInternalInconsistencyException
format:@"Should never create event for FKeepSyncedEventRegistration"];
2017-05-15 12:27:07 -07:00
return nil;
}
2019-08-05 13:27:47 -07:00
- (void)fireEvent:(id<FEvent>)event queue:(dispatch_queue_t)queue {
[NSException
raise:NSInternalInconsistencyException
format:@"Should never raise event for FKeepSyncedEventRegistration"];
2017-05-15 12:27:07 -07:00
}
2019-08-05 13:27:47 -07:00
- (FCancelEvent *)createCancelEventFromError:(NSError *)error
path:(FPath *)path {
2017-05-15 12:27:07 -07:00
// Don't create cancel events....
return nil;
}
2019-08-05 13:27:47 -07:00
- (FIRDatabaseHandle)handle {
// TODO[offline]: returning arbitray, can't return NSNotFound since that is
// used to match other event registrations We should really redo this to
// match on different kind of events (single observer, all observers,
// cancelled) rather than on a NSNotFound handle...
2017-05-15 12:27:07 -07:00
return NSNotFound - 1;
}
2019-08-05 13:27:47 -07:00
- (BOOL)matches:(id<FEventRegistration>)other {
2017-05-15 12:27:07 -07:00
// Only matches singleton instance
return self == other;
}
@end