Skip to content

Commit e2a463f

Browse files
committed
sync
1 parent 35edd28 commit e2a463f

File tree

4 files changed

+23
-29
lines changed

4 files changed

+23
-29
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public String getName() {
1919
}
2020

2121
@Override
22-
public void install(Promise promise) {
22+
public boolean install() {
2323
try {
2424
QuickSQLiteBridge.instance.install(getReactApplicationContext());
25-
promise.resolve(true);
25+
return true;
2626
} catch (Exception exception) {
2727
Log.e(NAME, "Failed to install JSI Bindings!", exception);
28-
promise.resolve(false);
28+
return false;
2929
}
3030
}
3131
}

package/ios/QuickSQLite.mm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
using namespace facebook;
99

10-
@implementation QuickSQLite
10+
@implementation RNQuickSQLiteInit
1111

1212
RCT_EXPORT_MODULE()
1313

@@ -17,18 +17,18 @@ @implementation QuickSQLite
1717
return std::make_shared<facebook::react::NativeRNQuickSQLiteInitSpecJSI>(params);
1818
}
1919

20-
- (void)install:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
20+
- (NSNumber *) install {
2121
NSLog(@"Installing QuickSQLite module...");
2222

2323
RCTBridge *bridge = [RCTBridge currentBridge];
2424
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
2525
if (cxxBridge == nil) {
26-
return resolve(@false);
26+
return @false;
2727
}
2828

2929
auto jsiRuntime = (jsi::Runtime *)cxxBridge.runtime;
3030
if (jsiRuntime == nil) {
31-
return resolve(@false);
31+
return @false;
3232
}
3333
auto &runtime = *jsiRuntime;
3434
auto callInvoker = bridge.jsCallInvoker;
@@ -44,7 +44,7 @@ - (void)install:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)re
4444

4545
if (storeUrl == nil) {
4646
NSLog(@"Invalid AppGroup ID provided (%@). Check the value of \"AppGroup\" in your Info.plist file", appGroupID);
47-
return resolve(@false);
47+
return @false;
4848
}
4949
NSLog(@"Configured with AppGroup ID: %@", appGroupID);
5050

@@ -56,7 +56,7 @@ - (void)install:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)re
5656
}
5757

5858
osp::install(runtime, callInvoker, [documentPath UTF8String]);
59-
return resolve(@true);
59+
return @true;
6060
}
6161

6262
@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(): Promise<boolean>
4+
install(): boolean
55
}
66

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

package/src/index.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
77
/* eslint-disable @typescript-eslint/no-unsafe-return */
88
/* eslint-disable @typescript-eslint/no-explicit-any */
9-
109
/* eslint-disable @typescript-eslint/no-unsafe-call */
1110

1211
import RNQuickSQLiteInit from './NativeRNQuickSQLiteInit'
@@ -16,8 +15,6 @@ declare global {
1615
var __QuickSQLiteProxy: object | undefined
1716
}
1817

19-
export let QuickSQLite: ISQLite | null
20-
2118
if (global.__QuickSQLiteProxy == null) {
2219
if (RNQuickSQLiteInit == null || RNQuickSQLiteInit.install == null) {
2320
throw new Error(
@@ -26,24 +23,21 @@ if (global.__QuickSQLiteProxy == null) {
2623
}
2724

2825
// Call the synchronous blocking install() function
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-
}
35-
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-
}
26+
const result = RNQuickSQLiteInit.install()
27+
if (result !== true) {
28+
throw new Error(
29+
`Failed to install react-native-quick-sqlite: The QuickSQLite TurboModule could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`
30+
)
31+
}
4232

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

4842
/**
4943
* Object returned by SQL Query executions {

0 commit comments

Comments
 (0)