[ios][database] update database events
This commit is contained in:
parent
887823162a
commit
56e9a1d5f6
|
@ -8,8 +8,7 @@ static NSString *const AUTH_ERROR_EVENT = @"authError";
|
|||
static NSString *const AUTH_ANONYMOUS_ERROR_EVENT = @"authAnonymousError";
|
||||
|
||||
// Database
|
||||
static NSString *const DATABASE_ON_EVENT = @"database_on_event";
|
||||
static NSString *const DATABASE_CANCEL_EVENT = @"database_cancel_event";
|
||||
static NSString *const DATABASE_SYNC_EVENT = @"database_sync_event";
|
||||
static NSString *const DATABASE_TRANSACTION_EVENT = @"database_transaction_event";
|
||||
|
||||
static NSString *const DATABASE_VALUE_EVENT = @"value";
|
||||
|
|
|
@ -476,7 +476,7 @@ RCT_EXPORT_METHOD(off:
|
|||
|
||||
|
||||
- (NSArray<NSString *> *)supportedEvents {
|
||||
return @[DATABASE_ON_EVENT, DATABASE_CANCEL_EVENT, DATABASE_TRANSACTION_EVENT];
|
||||
return @[DATABASE_SYNC_EVENT, DATABASE_TRANSACTION_EVENT];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
if (!_listeners[listenerId]) {
|
||||
id andPreviousSiblingKeyWithBlock = ^(FIRDataSnapshot *_Nonnull snapshot, NSString *_Nullable previousChildName) {
|
||||
NSDictionary *props = [RNFirebaseDatabaseReference snapshotToDict:snapshot];
|
||||
[self sendJSEvent:DATABASE_ON_EVENT title:eventName props:@{@"eventName": eventName, @"refId": _refId, @"listenerId": listenerId, @"path": _path, @"snapshot": props, @"previousChildName": previousChildName != nil ? previousChildName : [NSNull null]}];
|
||||
[self sendJSEvent:DATABASE_SYNC_EVENT title:eventName props:@{@"eventName": eventName, @"refId": _refId, @"listenerId": listenerId, @"path": _path, @"snapshot": props, @"previousChildName": previousChildName != nil ? previousChildName : [NSNull null]}];
|
||||
};
|
||||
id errorBlock = ^(NSError *_Nonnull error) {
|
||||
NSLog(@"Error onDBEvent: %@", [error debugDescription]);
|
||||
|
@ -130,13 +130,13 @@
|
|||
}
|
||||
|
||||
- (NSDictionary *)getAndSendDatabaseError:(NSError *)error listenerId:(NSNumber *)listenerId {
|
||||
NSDictionary *event = @{@"eventName": DATABASE_CANCEL_EVENT, @"path": _path, @"refId": _refId, @"listenerId": listenerId, @"code": @([error code]), @"details": [error debugDescription], @"message": [error localizedDescription], @"description": [error description]};
|
||||
NSDictionary *event = @{@"eventName": DATABASE_SYNC_EVENT, @"path": _path, @"refId": _refId, @"listenerId": listenerId, @"code": @([error code]), @"details": [error debugDescription], @"message": [error localizedDescription], @"description": [error description]};
|
||||
|
||||
@try {
|
||||
[_emitter sendEventWithName:DATABASE_CANCEL_EVENT body:event];
|
||||
[_emitter sendEventWithName:DATABASE_SYNC_EVENT body:event];
|
||||
} @catch (NSException *err) {
|
||||
NSLog(@"An error occurred in getAndSendDatabaseError: %@", [err debugDescription]);
|
||||
NSLog(@"Tried to send: %@ with %@", DATABASE_CANCEL_EVENT, event);
|
||||
NSLog(@"Tried to send: %@ with %@", DATABASE_SYNC_EVENT, event);
|
||||
}
|
||||
|
||||
return event;
|
||||
|
|
Loading…
Reference in New Issue