@react-native-firebase/database 25.1.0 → 26.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/RNFBDatabase.podspec +20 -7
- package/android/build.gradle +19 -0
- package/android/src/main/java/io/invertase/firebase/database/UniversalFirebaseDatabaseModule.java +4 -14
- package/android/src/reactnative/java/io/invertase/firebase/database/DatabaseTurboModuleSupport.java +56 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseModule.java → NativeRNFBTurboDatabase.java} +16 -36
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseOnDisconnectModule.java → NativeRNFBTurboDatabaseOnDisconnect.java} +19 -14
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseQueryModule.java → NativeRNFBTurboDatabaseQuery.java} +41 -105
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseReferenceModule.java → NativeRNFBTurboDatabaseReference.java} +27 -20
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseTransactionModule.java → NativeRNFBTurboDatabaseTransaction.java} +41 -19
- package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabasePackage.java +5 -5
- package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabaseTransactionHandler.java +11 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseOnDisconnectSpec.java +55 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseQuerySpec.java +52 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseReferenceSpec.java +55 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseSpec.java +57 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseTransactionSpec.java +42 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/CMakeLists.txt +36 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules-generated.cpp +182 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules.h +63 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI.h +440 -0
- package/dist/module/DatabaseDataSnapshot.js +20 -6
- package/dist/module/DatabaseDataSnapshot.js.map +1 -1
- package/dist/module/DatabaseOnDisconnect.js.map +1 -1
- package/dist/module/DatabaseQuery.js +13 -16
- package/dist/module/DatabaseQuery.js.map +1 -1
- package/dist/module/DatabaseReference.js +16 -15
- package/dist/module/DatabaseReference.js.map +1 -1
- package/dist/module/DatabaseSyncTree.js +5 -4
- package/dist/module/DatabaseSyncTree.js.map +1 -1
- package/dist/module/DatabaseThenableReference.js +1 -2
- package/dist/module/DatabaseThenableReference.js.map +1 -1
- package/dist/module/index.js +210 -5
- package/dist/module/index.js.map +1 -1
- package/dist/module/modular/query.js +14 -15
- package/dist/module/modular/query.js.map +1 -1
- package/dist/module/modular/transaction.js +1 -2
- package/dist/module/modular/transaction.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/web/RNFBDatabaseModule.js +4 -8
- package/dist/module/web/RNFBDatabaseModule.js.map +1 -1
- package/dist/typescript/lib/DatabaseDataSnapshot.d.ts +9 -7
- package/dist/typescript/lib/DatabaseDataSnapshot.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseOnDisconnect.d.ts +3 -3
- package/dist/typescript/lib/DatabaseOnDisconnect.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseQuery.d.ts +18 -18
- package/dist/typescript/lib/DatabaseQuery.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseReference.d.ts +8 -8
- package/dist/typescript/lib/DatabaseReference.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseSyncTree.d.ts +2 -2
- package/dist/typescript/lib/DatabaseSyncTree.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseThenableReference.d.ts +8 -8
- package/dist/typescript/lib/DatabaseThenableReference.d.ts.map +1 -1
- package/dist/typescript/lib/index.d.ts +57 -4
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/modular/query.d.ts.map +1 -1
- package/dist/typescript/lib/modular/transaction.d.ts.map +1 -1
- package/dist/typescript/lib/types/database.d.ts +5 -5
- package/dist/typescript/lib/types/database.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +32 -31
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/dist/typescript/lib/web/RNFBDatabaseModule.d.ts.map +1 -1
- package/ios/RNFBDatabase/RNFBDatabaseCommon.h +13 -6
- package/ios/RNFBDatabase/RNFBDatabaseCommon.m +2 -10
- package/ios/RNFBDatabase/RNFBDatabaseConstants.h +25 -0
- package/ios/RNFBDatabase/RNFBDatabaseModule.mm +90 -0
- package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.h +39 -0
- package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.m +64 -0
- package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectHelper.h +59 -0
- package/ios/RNFBDatabase/{RNFBDatabaseOnDisconnectModule.m → RNFBDatabaseOnDisconnectHelper.m} +41 -47
- package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectModule.mm +121 -0
- package/ios/RNFBDatabase/RNFBDatabaseQuery.h +11 -0
- package/ios/RNFBDatabase/RNFBDatabaseQueryHelper.h +49 -0
- package/ios/RNFBDatabase/{RNFBDatabaseQueryModule.m → RNFBDatabaseQueryHelper.m} +77 -91
- package/ios/RNFBDatabase/RNFBDatabaseQueryModule.h +5 -1
- package/ios/RNFBDatabase/RNFBDatabaseQueryModule.mm +105 -0
- package/ios/RNFBDatabase/RNFBDatabaseQueue.h +29 -0
- package/ios/RNFBDatabase/RNFBDatabaseQueue.m +31 -0
- package/ios/RNFBDatabase/RNFBDatabaseReferenceHelper.h +59 -0
- package/ios/RNFBDatabase/{RNFBDatabaseReferenceModule.m → RNFBDatabaseReferenceHelper.m} +42 -48
- package/ios/RNFBDatabase/RNFBDatabaseReferenceModule.mm +125 -0
- package/ios/RNFBDatabase/RNFBDatabaseTransactionHelper.h +38 -0
- package/ios/RNFBDatabase/{RNFBDatabaseTransactionModule.m → RNFBDatabaseTransactionHelper.m} +52 -51
- package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.h +0 -1
- package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.mm +86 -0
- package/ios/RNFBDatabase.xcodeproj/project.pbxproj +24 -24
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules-generated.mm +254 -0
- package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules.h +264 -0
- package/ios/generated/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
- package/ios/generated/RNFBDatabaseTurboModulesJSI.h +440 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/DatabaseDataSnapshot.ts +43 -38
- package/lib/DatabaseOnDisconnect.ts +3 -3
- package/lib/DatabaseQuery.ts +45 -77
- package/lib/DatabaseReference.ts +37 -66
- package/lib/DatabaseSyncTree.ts +8 -11
- package/lib/DatabaseThenableReference.ts +9 -17
- package/lib/index.ts +325 -6
- package/lib/modular/query.ts +14 -70
- package/lib/modular/transaction.ts +1 -4
- package/lib/types/database.ts +5 -5
- package/lib/types/internal.ts +31 -56
- package/lib/version.ts +1 -1
- package/lib/web/RNFBDatabaseModule.ts +6 -10
- package/package.json +26 -4
- package/react-native.config.js +10 -0
- package/specs/NativeRNFBTurboDatabase.ts +13 -0
- package/specs/NativeRNFBTurboDatabaseOnDisconnect.ts +18 -0
- package/specs/NativeRNFBTurboDatabaseQuery.ts +25 -0
- package/specs/NativeRNFBTurboDatabaseReference.ts +13 -0
- package/specs/NativeRNFBTurboDatabaseTransaction.ts +16 -0
- package/typedoc.json +1 -1
- package/dist/module/modular.js +0 -76
- package/dist/module/modular.js.map +0 -1
- package/dist/module/namespaced.js +0 -147
- package/dist/module/namespaced.js.map +0 -1
- package/dist/module/types/namespaced.js +0 -67
- package/dist/module/types/namespaced.js.map +0 -1
- package/dist/typescript/lib/modular.d.ts +0 -24
- package/dist/typescript/lib/modular.d.ts.map +0 -1
- package/dist/typescript/lib/namespaced.d.ts +0 -13
- package/dist/typescript/lib/namespaced.d.ts.map +0 -1
- package/dist/typescript/lib/types/namespaced.d.ts +0 -1230
- package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
- package/ios/RNFBDatabase/RNFBDatabaseModule.m +0 -100
- package/lib/modular.ts +0 -134
- package/lib/namespaced.ts +0 -253
- package/lib/types/namespaced.ts +0 -1366
package/ios/RNFBDatabase/{RNFBDatabaseOnDisconnectModule.m → RNFBDatabaseOnDisconnectHelper.m}
RENAMED
|
@@ -15,31 +15,25 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
#if __has_include(<Firebase/Firebase.h>)
|
|
18
19
|
#import <Firebase/Firebase.h>
|
|
19
|
-
#
|
|
20
|
+
#else
|
|
21
|
+
@import FirebaseCore;
|
|
22
|
+
@import FirebaseDatabaseInternal;
|
|
23
|
+
#endif
|
|
20
24
|
|
|
25
|
+
#import "RNFBApp/RCTConvert+FIRApp.h"
|
|
21
26
|
#import "RNFBDatabaseCommon.h"
|
|
22
|
-
#import "
|
|
27
|
+
#import "RNFBDatabaseOnDisconnectHelper.h"
|
|
23
28
|
|
|
24
|
-
@implementation
|
|
25
|
-
#pragma mark -
|
|
26
|
-
#pragma mark Module Setup
|
|
29
|
+
@implementation RNFBDatabaseOnDisconnectHelper
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
#pragma mark -
|
|
35
|
-
#pragma mark Firebase Database
|
|
36
|
-
|
|
37
|
-
RCT_EXPORT_METHOD(onDisconnectCancel
|
|
38
|
-
: (FIRApp *)firebaseApp
|
|
39
|
-
: (NSString *)dbURL
|
|
40
|
-
: (NSString *)path
|
|
41
|
-
: (RCTPromiseResolveBlock)resolve
|
|
42
|
-
: (RCTPromiseRejectBlock)reject) {
|
|
31
|
+
+ (void)onDisconnectCancel:(NSString *)app
|
|
32
|
+
dbURL:(NSString *)dbURL
|
|
33
|
+
path:(NSString *)path
|
|
34
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
35
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
36
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
43
37
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
44
38
|
FIRDatabaseReference *firDatabaseReference =
|
|
45
39
|
[RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
|
|
@@ -54,12 +48,12 @@ RCT_EXPORT_METHOD(onDisconnectCancel
|
|
|
54
48
|
}];
|
|
55
49
|
}
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
+ (void)onDisconnectRemove:(NSString *)app
|
|
52
|
+
dbURL:(NSString *)dbURL
|
|
53
|
+
path:(NSString *)path
|
|
54
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
55
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
56
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
63
57
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
64
58
|
FIRDatabaseReference *firDatabaseReference =
|
|
65
59
|
[RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
|
|
@@ -74,13 +68,13 @@ RCT_EXPORT_METHOD(onDisconnectRemove
|
|
|
74
68
|
}];
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
:
|
|
79
|
-
|
|
80
|
-
:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
+ (void)onDisconnectSet:(NSString *)app
|
|
72
|
+
dbURL:(NSString *)dbURL
|
|
73
|
+
path:(NSString *)path
|
|
74
|
+
props:(NSDictionary *)props
|
|
75
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
76
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
77
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
84
78
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
85
79
|
FIRDatabaseReference *firDatabaseReference =
|
|
86
80
|
[RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
|
|
@@ -95,13 +89,13 @@ RCT_EXPORT_METHOD(onDisconnectSet
|
|
|
95
89
|
}];
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
+ (void)onDisconnectSetWithPriority:(NSString *)app
|
|
93
|
+
dbURL:(NSString *)dbURL
|
|
94
|
+
path:(NSString *)path
|
|
95
|
+
props:(NSDictionary *)props
|
|
96
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
97
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
98
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
105
99
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
106
100
|
FIRDatabaseReference *firDatabaseReference =
|
|
107
101
|
[RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
|
|
@@ -117,13 +111,13 @@ RCT_EXPORT_METHOD(onDisconnectSetWithPriority
|
|
|
117
111
|
}];
|
|
118
112
|
}
|
|
119
113
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
114
|
+
+ (void)onDisconnectUpdate:(NSString *)app
|
|
115
|
+
dbURL:(NSString *)dbURL
|
|
116
|
+
path:(NSString *)path
|
|
117
|
+
props:(NSDictionary *)props
|
|
118
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
119
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
120
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
127
121
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
128
122
|
FIRDatabaseReference *firDatabaseReference =
|
|
129
123
|
[RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#import <React/RCTUtils.h>
|
|
19
|
+
|
|
20
|
+
#import "RNFBDatabaseOnDisconnectHelper.h"
|
|
21
|
+
#import "RNFBDatabaseOnDisconnectModule.h"
|
|
22
|
+
#import "RNFBDatabaseQueue.h"
|
|
23
|
+
#import "RNFBDatabaseTurboModules.h"
|
|
24
|
+
|
|
25
|
+
// NOTE: This module deliberately never imports Firebase Database headers.
|
|
26
|
+
// See RNFBDatabaseModule.mm for rationale. All Firebase Database calls are
|
|
27
|
+
// delegated to the plain Objective-C `RNFBDatabaseOnDisconnectHelper`.
|
|
28
|
+
|
|
29
|
+
@interface RNFBDatabaseOnDisconnectModule () <NativeRNFBTurboDatabaseOnDisconnectSpec,
|
|
30
|
+
RCTBridgeModule>
|
|
31
|
+
@end
|
|
32
|
+
|
|
33
|
+
@implementation RNFBDatabaseOnDisconnectModule
|
|
34
|
+
#pragma mark -
|
|
35
|
+
#pragma mark Module Setup
|
|
36
|
+
|
|
37
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
38
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
39
|
+
return std::make_shared<facebook::react::NativeRNFBTurboDatabaseOnDisconnectSpecJSI>(params);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
RCT_EXPORT_MODULE(NativeRNFBTurboDatabaseOnDisconnect);
|
|
43
|
+
|
|
44
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
45
|
+
return NO;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (dispatch_queue_t)methodQueue {
|
|
49
|
+
return [RNFBDatabaseQueue getDispatchQueue];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#pragma mark -
|
|
53
|
+
#pragma mark Firebase Database
|
|
54
|
+
|
|
55
|
+
- (void)onDisconnectCancel:(NSString *)app
|
|
56
|
+
dbURL:(NSString *)dbURL
|
|
57
|
+
path:(NSString *)path
|
|
58
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
59
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
60
|
+
[RNFBDatabaseOnDisconnectHelper onDisconnectCancel:app
|
|
61
|
+
dbURL:dbURL
|
|
62
|
+
path:path
|
|
63
|
+
resolve:resolve
|
|
64
|
+
reject:reject];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)onDisconnectRemove:(NSString *)app
|
|
68
|
+
dbURL:(NSString *)dbURL
|
|
69
|
+
path:(NSString *)path
|
|
70
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
71
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
72
|
+
[RNFBDatabaseOnDisconnectHelper onDisconnectRemove:app
|
|
73
|
+
dbURL:dbURL
|
|
74
|
+
path:path
|
|
75
|
+
resolve:resolve
|
|
76
|
+
reject:reject];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void)onDisconnectSet:(NSString *)app
|
|
80
|
+
dbURL:(NSString *)dbURL
|
|
81
|
+
path:(NSString *)path
|
|
82
|
+
props:(NSDictionary *)props
|
|
83
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
84
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
85
|
+
[RNFBDatabaseOnDisconnectHelper onDisconnectSet:app
|
|
86
|
+
dbURL:dbURL
|
|
87
|
+
path:path
|
|
88
|
+
props:props
|
|
89
|
+
resolve:resolve
|
|
90
|
+
reject:reject];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (void)onDisconnectSetWithPriority:(NSString *)app
|
|
94
|
+
dbURL:(NSString *)dbURL
|
|
95
|
+
path:(NSString *)path
|
|
96
|
+
props:(NSDictionary *)props
|
|
97
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
98
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
99
|
+
[RNFBDatabaseOnDisconnectHelper onDisconnectSetWithPriority:app
|
|
100
|
+
dbURL:dbURL
|
|
101
|
+
path:path
|
|
102
|
+
props:props
|
|
103
|
+
resolve:resolve
|
|
104
|
+
reject:reject];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
- (void)onDisconnectUpdate:(NSString *)app
|
|
108
|
+
dbURL:(NSString *)dbURL
|
|
109
|
+
path:(NSString *)path
|
|
110
|
+
props:(NSDictionary *)props
|
|
111
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
112
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
113
|
+
[RNFBDatabaseOnDisconnectHelper onDisconnectUpdate:app
|
|
114
|
+
dbURL:dbURL
|
|
115
|
+
path:path
|
|
116
|
+
props:props
|
|
117
|
+
resolve:resolve
|
|
118
|
+
reject:reject];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@end
|
|
@@ -15,7 +15,18 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
#if __has_include(<Firebase/Firebase.h>)
|
|
18
19
|
#import <Firebase/Firebase.h>
|
|
20
|
+
#elif __has_include(<FirebaseDatabase/FirebaseDatabase-Swift.h>)
|
|
21
|
+
// SPM: the declared product is the thin Swift wrapper `FirebaseDatabase`
|
|
22
|
+
// (which depends on `FirebaseDatabaseInternal`, not exposed to us directly).
|
|
23
|
+
// Its generated ObjC interface header is what's importable here.
|
|
24
|
+
#import <FirebaseCore/FirebaseCore.h>
|
|
25
|
+
#import <FirebaseDatabase/FirebaseDatabase-Swift.h>
|
|
26
|
+
#else
|
|
27
|
+
@import FirebaseCore;
|
|
28
|
+
@import FirebaseDatabaseInternal;
|
|
29
|
+
#endif
|
|
19
30
|
#import <React/RCTBridgeModule.h>
|
|
20
31
|
|
|
21
32
|
@interface RNFBDatabaseQuery : NSObject
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#import <Foundation/Foundation.h>
|
|
19
|
+
#import <React/RCTBridgeModule.h>
|
|
20
|
+
|
|
21
|
+
// See RNFBDatabaseModuleHelper.h for rationale: plain Objective-C helper
|
|
22
|
+
// that owns all `FIRDatabaseQuery`/`FIRDataSnapshot` calls and the query
|
|
23
|
+
// listener bookkeeping for RNFBDatabaseQueryModule.
|
|
24
|
+
@interface RNFBDatabaseQueryHelper : NSObject
|
|
25
|
+
|
|
26
|
+
+ (void)once:(NSString *)app
|
|
27
|
+
dbURL:(NSString *)dbURL
|
|
28
|
+
path:(NSString *)path
|
|
29
|
+
modifiers:(NSArray *)modifiers
|
|
30
|
+
eventType:(NSString *)eventType
|
|
31
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
32
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
33
|
+
|
|
34
|
+
+ (void)on:(NSString *)app dbURL:(NSString *)dbURL props:(NSDictionary *)props;
|
|
35
|
+
|
|
36
|
+
+ (void)off:(NSString *)queryKey eventRegistrationKey:(NSString *)eventRegistrationKey;
|
|
37
|
+
|
|
38
|
+
+ (void)keepSynced:(NSString *)app
|
|
39
|
+
dbURL:(NSString *)dbURL
|
|
40
|
+
key:(NSString *)key
|
|
41
|
+
path:(NSString *)path
|
|
42
|
+
modifiers:(NSArray *)modifiers
|
|
43
|
+
enabled:(BOOL)value
|
|
44
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
45
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
46
|
+
|
|
47
|
+
+ (void)invalidate;
|
|
48
|
+
|
|
49
|
+
@end
|
|
@@ -15,57 +15,52 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
#
|
|
19
|
-
|
|
18
|
+
#if __has_include(<Firebase/Firebase.h>)
|
|
19
|
+
#import <Firebase/Firebase.h>
|
|
20
|
+
#else
|
|
21
|
+
@import FirebaseCore;
|
|
22
|
+
@import FirebaseDatabaseInternal;
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#import "RNFBApp/RCTConvert+FIRApp.h"
|
|
20
26
|
#import "RNFBDatabaseCommon.h"
|
|
21
27
|
#import "RNFBDatabaseQuery.h"
|
|
22
|
-
#import "
|
|
28
|
+
#import "RNFBDatabaseQueryHelper.h"
|
|
23
29
|
#import "RNFBRCTEventEmitter.h"
|
|
24
30
|
|
|
25
31
|
static __strong NSMutableDictionary *queryDictionary;
|
|
26
32
|
static NSString *const RNFB_DATABASE_SYNC = @"database_sync_event";
|
|
27
33
|
|
|
28
|
-
@implementation
|
|
29
|
-
#pragma mark -
|
|
30
|
-
#pragma mark Module Setup
|
|
31
|
-
|
|
32
|
-
RCT_EXPORT_MODULE();
|
|
33
|
-
|
|
34
|
-
- (dispatch_queue_t)methodQueue {
|
|
35
|
-
return [RNFBDatabaseCommon getDispatchQueue];
|
|
36
|
-
}
|
|
34
|
+
@implementation RNFBDatabaseQueryHelper
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
self = [super init];
|
|
36
|
+
+ (NSMutableDictionary *)queryDictionary {
|
|
40
37
|
static dispatch_once_t onceToken;
|
|
41
38
|
dispatch_once(&onceToken, ^{
|
|
42
39
|
queryDictionary = [[NSMutableDictionary alloc] init];
|
|
43
40
|
});
|
|
44
|
-
return
|
|
41
|
+
return queryDictionary;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
[self
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- (void)invalidate {
|
|
52
|
-
NSArray *queryKeys = [queryDictionary allKeys];
|
|
44
|
+
+ (void)invalidate {
|
|
45
|
+
NSMutableDictionary *queries = [self queryDictionary];
|
|
46
|
+
NSArray *queryKeys = [queries allKeys];
|
|
53
47
|
for (NSString *key in queryKeys) {
|
|
54
|
-
RNFBDatabaseQuery *query =
|
|
48
|
+
RNFBDatabaseQuery *query = queries[key];
|
|
55
49
|
[query removeAllEventListeners];
|
|
56
|
-
[
|
|
50
|
+
[queries removeObjectForKey:key];
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
|
|
54
|
+
+ (RNFBDatabaseQuery *)getDatabaseQueryInstance:(FIRDatabaseReference *)reference
|
|
61
55
|
modifiers:(NSArray *)modifiers {
|
|
62
56
|
return [[RNFBDatabaseQuery alloc] initWithReferenceAndModifiers:reference modifiers:modifiers];
|
|
63
57
|
}
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
+ (RNFBDatabaseQuery *)getDatabaseQueryInstance:(NSString *)key
|
|
66
60
|
reference:(FIRDatabaseReference *)reference
|
|
67
61
|
modifiers:(NSArray *)modifiers {
|
|
68
|
-
|
|
62
|
+
NSMutableDictionary *queries = [self queryDictionary];
|
|
63
|
+
RNFBDatabaseQuery *cachedQuery = queries[key];
|
|
69
64
|
|
|
70
65
|
if (cachedQuery != nil) {
|
|
71
66
|
return cachedQuery;
|
|
@@ -74,18 +69,17 @@ RCT_EXPORT_MODULE();
|
|
|
74
69
|
RNFBDatabaseQuery *query = [[RNFBDatabaseQuery alloc] initWithReferenceAndModifiers:reference
|
|
75
70
|
modifiers:modifiers];
|
|
76
71
|
|
|
77
|
-
|
|
72
|
+
queries[key] = query;
|
|
78
73
|
return query;
|
|
79
74
|
}
|
|
80
75
|
|
|
81
|
-
|
|
76
|
+
+ (void)addOnceEventListener:(RNFBDatabaseQuery *)databaseQuery
|
|
82
77
|
eventType:(NSString *)eventType
|
|
83
78
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
84
79
|
reject:(RCTPromiseRejectBlock)reject {
|
|
85
80
|
FIRDataEventType firDataEventType =
|
|
86
81
|
(FIRDataEventType)[RNFBDatabaseCommon getEventTypeFromName:eventType];
|
|
87
82
|
|
|
88
|
-
// On success
|
|
89
83
|
id andPreviousSiblingKeyWithBlock =
|
|
90
84
|
^(FIRDataSnapshot *_Nonnull dataSnapshot, NSString *_Nullable previousChildName) {
|
|
91
85
|
NSDictionary *data;
|
|
@@ -98,7 +92,6 @@ RCT_EXPORT_MODULE();
|
|
|
98
92
|
resolve(data);
|
|
99
93
|
};
|
|
100
94
|
|
|
101
|
-
// On error
|
|
102
95
|
id errorBlock = ^(NSError *_Nonnull error) {
|
|
103
96
|
[RNFBDatabaseCommon promiseRejectDatabaseException:reject error:error];
|
|
104
97
|
};
|
|
@@ -108,36 +101,7 @@ RCT_EXPORT_MODULE();
|
|
|
108
101
|
withCancelBlock:errorBlock];
|
|
109
102
|
}
|
|
110
103
|
|
|
111
|
-
|
|
112
|
-
eventType:(NSString *)eventType
|
|
113
|
-
registration:(NSDictionary *)registration {
|
|
114
|
-
NSString *eventRegistrationKey = registration[@"eventRegistrationKey"];
|
|
115
|
-
|
|
116
|
-
if (![databaseQuery hasEventListener:eventRegistrationKey]) {
|
|
117
|
-
id andPreviousSiblingKeyWithBlock =
|
|
118
|
-
^(FIRDataSnapshot *_Nonnull dataSnapshot, NSString *_Nullable previousChildName) {
|
|
119
|
-
[self handleDatabaseEvent:eventRegistrationKey
|
|
120
|
-
eventType:eventType
|
|
121
|
-
registration:registration
|
|
122
|
-
snapshot:dataSnapshot
|
|
123
|
-
previousChildName:previousChildName];
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
id errorBlock = ^(NSError *_Nonnull error) {
|
|
127
|
-
[databaseQuery removeEventListener:eventRegistrationKey];
|
|
128
|
-
[self handleDatabaseEventError:eventRegistrationKey registration:registration error:error];
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
FIRDataEventType firDataEventType =
|
|
132
|
-
(FIRDataEventType)[RNFBDatabaseCommon getEventTypeFromName:eventType];
|
|
133
|
-
FIRDatabaseHandle handle = [databaseQuery.query observeEventType:firDataEventType
|
|
134
|
-
andPreviousSiblingKeyWithBlock:andPreviousSiblingKeyWithBlock
|
|
135
|
-
withCancelBlock:errorBlock];
|
|
136
|
-
[databaseQuery addEventListener:eventRegistrationKey handle:handle];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
- (void)handleDatabaseEvent:(NSString *)key
|
|
104
|
+
+ (void)handleDatabaseEvent:(NSString *)key
|
|
141
105
|
eventType:(NSString *)eventType
|
|
142
106
|
registration:(NSDictionary *)registration
|
|
143
107
|
snapshot:(FIRDataSnapshot *)dataSnapshot
|
|
@@ -161,7 +125,7 @@ RCT_EXPORT_MODULE();
|
|
|
161
125
|
}];
|
|
162
126
|
}
|
|
163
127
|
|
|
164
|
-
|
|
128
|
+
+ (void)handleDatabaseEventError:(NSString *)key
|
|
165
129
|
registration:(NSDictionary *)registration
|
|
166
130
|
error:(NSError *)error {
|
|
167
131
|
NSArray *codeAndMessage = [RNFBDatabaseCommon getCodeAndMessage:error];
|
|
@@ -178,17 +142,43 @@ RCT_EXPORT_MODULE();
|
|
|
178
142
|
}];
|
|
179
143
|
}
|
|
180
144
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
145
|
+
+ (void)addEventListener:(RNFBDatabaseQuery *)databaseQuery
|
|
146
|
+
eventType:(NSString *)eventType
|
|
147
|
+
registration:(NSDictionary *)registration {
|
|
148
|
+
NSString *eventRegistrationKey = registration[@"eventRegistrationKey"];
|
|
149
|
+
|
|
150
|
+
if (![databaseQuery hasEventListener:eventRegistrationKey]) {
|
|
151
|
+
id andPreviousSiblingKeyWithBlock =
|
|
152
|
+
^(FIRDataSnapshot *_Nonnull dataSnapshot, NSString *_Nullable previousChildName) {
|
|
153
|
+
[self handleDatabaseEvent:eventRegistrationKey
|
|
154
|
+
eventType:eventType
|
|
155
|
+
registration:registration
|
|
156
|
+
snapshot:dataSnapshot
|
|
157
|
+
previousChildName:previousChildName];
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
id errorBlock = ^(NSError *_Nonnull error) {
|
|
161
|
+
[databaseQuery removeEventListener:eventRegistrationKey];
|
|
162
|
+
[self handleDatabaseEventError:eventRegistrationKey registration:registration error:error];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
FIRDataEventType firDataEventType =
|
|
166
|
+
(FIRDataEventType)[RNFBDatabaseCommon getEventTypeFromName:eventType];
|
|
167
|
+
FIRDatabaseHandle handle = [databaseQuery.query observeEventType:firDataEventType
|
|
168
|
+
andPreviousSiblingKeyWithBlock:andPreviousSiblingKeyWithBlock
|
|
169
|
+
withCancelBlock:errorBlock];
|
|
170
|
+
[databaseQuery addEventListener:eventRegistrationKey handle:handle];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
+ (void)once:(NSString *)app
|
|
175
|
+
dbURL:(NSString *)dbURL
|
|
176
|
+
path:(NSString *)path
|
|
177
|
+
modifiers:(NSArray *)modifiers
|
|
178
|
+
eventType:(NSString *)eventType
|
|
179
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
180
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
181
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
192
182
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
193
183
|
FIRDatabaseReference *firDatabaseReference =
|
|
194
184
|
[RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
|
|
@@ -198,13 +188,14 @@ RCT_EXPORT_METHOD(once
|
|
|
198
188
|
[self addOnceEventListener:databaseQuery eventType:eventType resolve:resolve reject:reject];
|
|
199
189
|
}
|
|
200
190
|
|
|
201
|
-
|
|
191
|
+
+ (void)on:(NSString *)app dbURL:(NSString *)dbURL props:(NSDictionary *)props {
|
|
202
192
|
NSString *key = [props valueForKey:@"key"];
|
|
203
193
|
NSString *path = [props valueForKey:@"path"];
|
|
204
194
|
NSString *eventType = [props valueForKey:@"eventType"];
|
|
205
195
|
NSArray *modifiers = [props valueForKey:@"modifiers"];
|
|
206
196
|
NSDictionary *registration = [props valueForKey:@"registration"];
|
|
207
197
|
|
|
198
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
208
199
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
209
200
|
FIRDatabaseReference *firDatabaseReference =
|
|
210
201
|
[RNFBDatabaseCommon getReferenceForDatabase:key firebaseDatabase:firDatabase path:path];
|
|
@@ -214,30 +205,29 @@ RCT_EXPORT_METHOD(on : (FIRApp *)firebaseApp : (NSString *)dbURL : (NSDictionary
|
|
|
214
205
|
[self addEventListener:databaseQuery eventType:eventType registration:registration];
|
|
215
206
|
}
|
|
216
207
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
RNFBDatabaseQuery *databaseQuery = queryDictionary[queryKey];
|
|
208
|
+
+ (void)off:(NSString *)queryKey eventRegistrationKey:(NSString *)eventRegistrationKey {
|
|
209
|
+
NSMutableDictionary *queries = [self queryDictionary];
|
|
210
|
+
RNFBDatabaseQuery *databaseQuery = queries[queryKey];
|
|
221
211
|
|
|
222
212
|
if (databaseQuery != nil) {
|
|
223
213
|
[databaseQuery removeEventListener:eventRegistrationKey];
|
|
224
214
|
|
|
225
215
|
if (![databaseQuery hasListeners]) {
|
|
226
|
-
[
|
|
216
|
+
[queries removeObjectForKey:queryKey];
|
|
227
217
|
[RNFBDatabaseCommon removeReferenceByKey:queryKey];
|
|
228
218
|
}
|
|
229
219
|
}
|
|
230
220
|
}
|
|
231
221
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
222
|
+
+ (void)keepSynced:(NSString *)app
|
|
223
|
+
dbURL:(NSString *)dbURL
|
|
224
|
+
key:(NSString *)key
|
|
225
|
+
path:(NSString *)path
|
|
226
|
+
modifiers:(NSArray *)modifiers
|
|
227
|
+
enabled:(BOOL)value
|
|
228
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
229
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
230
|
+
FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
|
|
241
231
|
FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
|
|
242
232
|
FIRDatabaseReference *firDatabaseReference =
|
|
243
233
|
[RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
|
|
@@ -247,8 +237,4 @@ RCT_EXPORT_METHOD(keepSynced
|
|
|
247
237
|
resolve([NSNull null]);
|
|
248
238
|
}
|
|
249
239
|
|
|
250
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
251
|
-
return YES;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
240
|
@end
|
|
@@ -15,9 +15,13 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
#import <Firebase/Firebase.h>
|
|
19
18
|
#import <Foundation/Foundation.h>
|
|
20
19
|
#import <React/RCTBridgeModule.h>
|
|
21
20
|
|
|
21
|
+
// NOTE: This header must stay Firebase-free. It is imported by
|
|
22
|
+
// RNFBDatabaseQueryModule.mm, and `FirebaseDatabase` is a Swift-only SPM
|
|
23
|
+
// product whose `@import` cannot be used from Objective-C++ (.mm) files
|
|
24
|
+
// when C++ modules are disabled. See RNFBDatabaseModule.mm for details.
|
|
25
|
+
|
|
22
26
|
@interface RNFBDatabaseQueryModule : NSObject <RCTBridgeModule>
|
|
23
27
|
@end
|