Skip to content

Commit 35edd28

Browse files
committed
async
1 parent c2fa3fd commit 35edd28

File tree

6 files changed

+142
-50
lines changed

6 files changed

+142
-50
lines changed

example/ios/Podfile.lock

Lines changed: 97 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,71 @@ PODS:
12591259
- ReactCommon/turbomodule/core
12601260
- Yoga
12611261
- react-native-safe-area-context (4.11.0):
1262+
- DoubleConversion
1263+
- glog
1264+
- hermes-engine
1265+
- RCT-Folly (= 2024.01.01.00)
1266+
- RCTRequired
1267+
- RCTTypeSafety
1268+
- React-Core
1269+
- React-debug
1270+
- React-Fabric
1271+
- React-featureflags
1272+
- React-graphics
1273+
- React-ImageManager
1274+
- react-native-safe-area-context/common (= 4.11.0)
1275+
- react-native-safe-area-context/fabric (= 4.11.0)
1276+
- React-NativeModulesApple
1277+
- React-RCTFabric
1278+
- React-rendererdebug
1279+
- React-utils
1280+
- ReactCodegen
1281+
- ReactCommon/turbomodule/bridging
1282+
- ReactCommon/turbomodule/core
1283+
- Yoga
1284+
- react-native-safe-area-context/common (4.11.0):
1285+
- DoubleConversion
1286+
- glog
1287+
- hermes-engine
1288+
- RCT-Folly (= 2024.01.01.00)
1289+
- RCTRequired
1290+
- RCTTypeSafety
1291+
- React-Core
1292+
- React-debug
1293+
- React-Fabric
1294+
- React-featureflags
1295+
- React-graphics
1296+
- React-ImageManager
1297+
- React-NativeModulesApple
1298+
- React-RCTFabric
1299+
- React-rendererdebug
1300+
- React-utils
1301+
- ReactCodegen
1302+
- ReactCommon/turbomodule/bridging
1303+
- ReactCommon/turbomodule/core
1304+
- Yoga
1305+
- react-native-safe-area-context/fabric (4.11.0):
1306+
- DoubleConversion
1307+
- glog
1308+
- hermes-engine
1309+
- RCT-Folly (= 2024.01.01.00)
1310+
- RCTRequired
1311+
- RCTTypeSafety
12621312
- React-Core
1313+
- React-debug
1314+
- React-Fabric
1315+
- React-featureflags
1316+
- React-graphics
1317+
- React-ImageManager
1318+
- react-native-safe-area-context/common
1319+
- React-NativeModulesApple
1320+
- React-RCTFabric
1321+
- React-rendererdebug
1322+
- React-utils
1323+
- ReactCodegen
1324+
- ReactCommon/turbomodule/bridging
1325+
- ReactCommon/turbomodule/core
1326+
- Yoga
12631327
- React-nativeconfig (0.75.2)
12641328
- React-NativeModulesApple (0.75.2):
12651329
- glog
@@ -1521,6 +1585,29 @@ PODS:
15211585
- React-perflogger (= 0.75.2)
15221586
- React-utils (= 0.75.2)
15231587
- RNScreens (3.34.0):
1588+
- DoubleConversion
1589+
- glog
1590+
- hermes-engine
1591+
- RCT-Folly (= 2024.01.01.00)
1592+
- RCTRequired
1593+
- RCTTypeSafety
1594+
- React-Core
1595+
- React-debug
1596+
- React-Fabric
1597+
- React-featureflags
1598+
- React-graphics
1599+
- React-ImageManager
1600+
- React-NativeModulesApple
1601+
- React-RCTFabric
1602+
- React-RCTImage
1603+
- React-rendererdebug
1604+
- React-utils
1605+
- ReactCodegen
1606+
- ReactCommon/turbomodule/bridging
1607+
- ReactCommon/turbomodule/core
1608+
- RNScreens/common (= 3.34.0)
1609+
- Yoga
1610+
- RNScreens/common (3.34.0):
15241611
- DoubleConversion
15251612
- glog
15261613
- hermes-engine
@@ -1768,16 +1855,16 @@ SPEC CHECKSUMS:
17681855
React-CoreModules: f92a2cb11d22f6066823ca547c61e900325dfe44
17691856
React-cxxreact: f5595a4cbfe5a4e9d401dffa2c1c78bbbbbe75e4
17701857
React-debug: 4a91c177b5b2efcc546fb50bc2f676f3f589efab
1771-
React-defaultsnativemodule: bb94c3db425b01c760f41a253de8536b3f5497f0
1772-
React-domnativemodule: 6c581fd39812cafb024171e091c00905b2c3a3e2
1858+
React-defaultsnativemodule: 6b666572abf5fe7fe87836a42776abd6ad5ed173
1859+
React-domnativemodule: 785d767c4edbb9f011b8c976271077759ca5c4aa
17731860
React-Fabric: a33cc1fdc62a3085774783bb30970531589d2028
17741861
React-FabricComponents: 98de5f94cbd35d407f4fc78855298b562d8289cb
17751862
React-FabricImage: 0ce8fd83844d9edef5825116d38f0e208b9ad786
17761863
React-featureflags: 37a78859ad71db758e2efdcbdb7384afefa8701e
1777-
React-featureflagsnativemodule: 52b46e161a151b4653cf1762285e8e899d534e3f
1864+
React-featureflagsnativemodule: f94aacb52c463e200ee185bff90ae3b392e60263
17781865
React-graphics: c16f1bab97a5d473831a79360d84300e93a614e5
17791866
React-hermes: 7801f8c0e12f326524b461dc368d3e74f3d2a385
1780-
React-idlecallbacksnativemodule: 58de2ac968ee80947d19dc8fe20def607e5c2de8
1867+
React-idlecallbacksnativemodule: d81bb7b5d26cea9852a8edc6ad1979cd7ed0841f
17811868
React-ImageManager: 98a1e5b0b05528dde47ebcd953d916ac66d46c09
17821869
React-jserrorhandler: 08f1c3465a71a6549c27ad82809ce145ad52d4f1
17831870
React-jsi: 161428ab2c706d5fcd9878d260ff1513fdb356ab
@@ -1786,18 +1873,18 @@ SPEC CHECKSUMS:
17861873
React-jsitracing: 52b849a77d02e2dc262a3031454c23be8dabb4d9
17871874
React-logger: 8db32983d75dc2ad54f278f344ccb9b256e694fc
17881875
React-Mapbuffer: 1c08607305558666fd16678b85ef135e455d5c96
1789-
React-microtasksnativemodule: 87b8de96f937faefece8afd2cb3a518321b2ef99
1790-
react-native-quick-sqlite: b681131e6c1a741be3c928beba30722efbd4933b
1791-
react-native-safe-area-context: 851c62c48dce80ccaa5637b6aa5991a1bc36eca9
1876+
React-microtasksnativemodule: f13f03163b6a5ec66665dfe80a0df4468bb766a6
1877+
react-native-quick-sqlite: 9d2ea1b980fff3b5a39c61db61731ff405f0ce13
1878+
react-native-safe-area-context: f1fda705dfe14355f41933debb5932887e234cc5
17921879
React-nativeconfig: 57781b79e11d5af7573e6f77cbf1143b71802a6d
17931880
React-NativeModulesApple: 7ff2e2cfb2e5fa5bdedcecf28ce37e696c6ef1e1
17941881
React-perflogger: 8a360ccf603de6ddbe9ff8f54383146d26e6c936
17951882
React-performancetimeline: 3cfec915adcb3653a5a633b41e711903844c35d8
17961883
React-RCTActionSheet: 1c0e26a88eec41215089cf4436e38188cfe9f01a
17971884
React-RCTAnimation: d87207841b1e2ae1389e684262ea8c73c887cb04
1798-
React-RCTAppDelegate: 4ec7824c0cc9cc4b146ca8ee0fd81b10c316a440
1885+
React-RCTAppDelegate: 328e56399c4f1c3d20cfe547ea24ebded2b3a87f
17991886
React-RCTBlob: 79b42cb7db55f34079297687a480dbcf37f023f6
1800-
React-RCTFabric: 1dd1661db93716f8cb116e451bd9c211a8d15716
1887+
React-RCTFabric: 27636a6a5fa5622159297fce26881945d3658cf6
18011888
React-RCTImage: 0c10a75de59f7384a2a55545d5f36fe783e6ecda
18021889
React-RCTLinking: bf08f4f655bf777af292b8d97449072c8bb196ca
18031890
React-RCTNetwork: 1b690846b40fc5685af58e088720657db6814637
@@ -1815,7 +1902,7 @@ SPEC CHECKSUMS:
18151902
React-utils: 81a715d9c0a2a49047e77a86f3a2247408540deb
18161903
ReactCodegen: 4eedb2fdd079174d6fc3c80b1cccafbe4ff1be8d
18171904
ReactCommon: 6ef348087d250257c44c0204461c03f036650e9b
1818-
RNScreens: 19719a9c326e925498ac3b2d35c4e50fe87afc06
1905+
RNScreens: de6e57426ba0e6cbc3fb5b4f496e7f08cb2773c2
18191906
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
18201907
Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8
18211908

package/android/src/main/java/com/margelo/rnquicksqlite/RNQuickSQLiteInitModule.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.util.Log;
44

55
import androidx.annotation.NonNull;
6+
7+
import com.facebook.react.bridge.Promise;
68
import com.facebook.react.bridge.ReactApplicationContext;
79

810
public class RNQuickSQLiteInitModule extends NativeRNQuickSQLiteInitSpec {
@@ -17,13 +19,13 @@ public String getName() {
1719
}
1820

1921
@Override
20-
public boolean install() {
22+
public void install(Promise promise) {
2123
try {
2224
QuickSQLiteBridge.instance.install(getReactApplicationContext());
23-
return true;
25+
promise.resolve(true);
2426
} catch (Exception exception) {
2527
Log.e(NAME, "Failed to install JSI Bindings!", exception);
26-
return false;
28+
promise.resolve(false);
2729
}
2830
}
2931
}

package/ios/QuickSQLite.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
#import <React/RCTBridgeModule.h>
2-
#import <React/RCTInvalidating.h>
1+
#import <RNQuickSQLite/RNQuickSQLite.h>
32

4-
@interface QuickSQLite : NSObject <RCTBridgeModule, RCTInvalidating>
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
@interface RNQuickSQLiteInit : NSObject <NativeRNQuickSQLiteInitSpec>
56

67
@property(nonatomic, assign) BOOL setBridgeOnMainQueue;
78

89
@end
10+
11+
NS_ASSUME_NONNULL_END

package/ios/QuickSQLite.mm

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
#import "QuickSQLite.h"
2-
3-
#import <React/RCTBridge+Private.h>
4-
51
#import <React/RCTUtils.h>
2+
#import <React/RCTBridge+Private.h>
63
#import <ReactCommon/RCTTurboModule.h>
74
#import <jsi/jsi.h>
8-
5+
#import "QuickSQLite.h"
96
#import "../cpp/bindings.h"
107

8+
using namespace facebook;
9+
1110
@implementation QuickSQLite
1211

13-
RCT_EXPORT_MODULE(QuickSQLite)
12+
RCT_EXPORT_MODULE()
1413

14+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
15+
(const facebook::react::ObjCTurboModule::InitParams &)params
16+
{
17+
return std::make_shared<facebook::react::NativeRNQuickSQLiteInitSpecJSI>(params);
18+
}
1519

16-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
20+
- (void)install:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
1721
NSLog(@"Installing QuickSQLite module...");
1822

1923
RCTBridge *bridge = [RCTBridge currentBridge];
2024
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
2125
if (cxxBridge == nil) {
22-
return @false;
26+
return resolve(@false);
2327
}
2428

25-
using namespace facebook;
26-
2729
auto jsiRuntime = (jsi::Runtime *)cxxBridge.runtime;
2830
if (jsiRuntime == nil) {
29-
return @false;
31+
return resolve(@false);
3032
}
3133
auto &runtime = *jsiRuntime;
3234
auto callInvoker = bridge.jsCallInvoker;
@@ -42,7 +44,7 @@ @implementation QuickSQLite
4244

4345
if (storeUrl == nil) {
4446
NSLog(@"Invalid AppGroup ID provided (%@). Check the value of \"AppGroup\" in your Info.plist file", appGroupID);
45-
return @false;
47+
return resolve(@false);
4648
}
4749
NSLog(@"Configured with AppGroup ID: %@", appGroupID);
4850

@@ -54,12 +56,7 @@ @implementation QuickSQLite
5456
}
5557

5658
osp::install(runtime, callInvoker, [documentPath UTF8String]);
57-
return @true;
59+
return resolve(@true);
5860
}
5961

60-
- (void)invalidate {
61-
osp::clearState();
62-
}
63-
64-
6562
@end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TurboModuleRegistry, type TurboModule } from 'react-native'
22

33
export interface Spec extends TurboModule {
4-
install(): boolean
4+
install(): Promise<boolean>
55
}
66

77
export default TurboModuleRegistry.getEnforcing<Spec>('RNQuickSQLiteInit')

package/src/index.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ declare global {
1616
var __QuickSQLiteProxy: object | undefined
1717
}
1818

19+
export let QuickSQLite: ISQLite | null
20+
1921
if (global.__QuickSQLiteProxy == null) {
2022
if (RNQuickSQLiteInit == null || RNQuickSQLiteInit.install == null) {
2123
throw new Error(
@@ -24,23 +26,24 @@ if (global.__QuickSQLiteProxy == null) {
2426
}
2527

2628
// Call the synchronous blocking install() function
27-
const result = RNQuickSQLiteInit.install()
28-
if (result !== true) {
29-
throw new Error(
30-
`Failed to install react-native-quick-sqlite: The QuickSQLite TurboModule could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`
31-
)
32-
}
29+
RNQuickSQLiteInit.install().then((result) => {
30+
if (result !== true) {
31+
throw new Error(
32+
`Failed to install react-native-quick-sqlite: The QuickSQLite TurboModule could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`
33+
)
34+
}
3335

34-
// Check again if the constructor now exists. If not, throw an error.
35-
if (global.__QuickSQLiteProxy == null) {
36-
throw new Error(
37-
'Failed to install react-native-quick-sqlite, the native initializer function does not exist. Are you trying to use QuickSQLite from different JS Runtimes?'
38-
)
39-
}
40-
}
36+
// Check again if the constructor now exists. If not, throw an error.
37+
if (global.__QuickSQLiteProxy == null) {
38+
throw new Error(
39+
'Failed to install react-native-quick-sqlite, the native initializer function does not exist. Are you trying to use QuickSQLite from different JS Runtimes?'
40+
)
41+
}
4142

42-
const proxy = global.__QuickSQLiteProxy
43-
export const QuickSQLite = proxy as ISQLite
43+
QuickSQLite = global.__QuickSQLiteProxy as ISQLite
44+
})
45+
}
46+
QuickSQLite = global.__QuickSQLiteProxy as ISQLite
4447

4548
/**
4649
* Object returned by SQL Query executions {

0 commit comments

Comments
 (0)