@onekeyfe/react-native-background-thread 1.1.9 → 1.1.10
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/android/src/main/java/com/backgroundthread/BackgroundThreadModule.kt +4 -0
- package/ios/BackgroundThread.mm +17 -5
- package/ios/BackgroundThreadManager.h +4 -0
- package/ios/BackgroundThreadManager.mm +8 -1
- package/lib/module/NativeBackgroundThread.js.map +1 -1
- package/lib/typescript/src/NativeBackgroundThread.d.ts +1 -0
- package/lib/typescript/src/NativeBackgroundThread.d.ts.map +1 -1
- package/package.json +1 -5
- package/src/NativeBackgroundThread.ts +1 -0
|
@@ -11,6 +11,10 @@ class BackgroundThreadModule(reactContext: ReactApplicationContext) :
|
|
|
11
11
|
return NAME
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
override fun initBackgroundThread() {
|
|
15
|
+
// TODO: Implement initBackgroundThread
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
override fun postBackgroundMessage(message: String) {
|
|
15
19
|
// TODO: Implement postBackgroundMessage
|
|
16
20
|
}
|
package/ios/BackgroundThread.mm
CHANGED
|
@@ -16,19 +16,31 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
- (void)startBackgroundRunnerWithEntryURL:(NSString *)entryURL {
|
|
19
|
+
BackgroundThreadManager *manager = [BackgroundThreadManager sharedInstance];
|
|
20
|
+
[manager startBackgroundRunnerWithEntryURL:entryURL];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Force register event callback during initialization
|
|
24
|
+
// This is mainly to handle the scenario of restarting in development environment
|
|
25
|
+
- (void)initBackgroundThread {
|
|
26
|
+
[self bindMessageCallback];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (void)bindMessageCallback {
|
|
19
30
|
BackgroundThreadManager *manager = [BackgroundThreadManager sharedInstance];
|
|
20
|
-
|
|
21
|
-
// Set up message callback to bridge it back through this instance
|
|
22
31
|
__weak __typeof__(self) weakSelf = self;
|
|
23
32
|
[manager setOnMessageCallback:^(NSString *message) {
|
|
24
33
|
[weakSelf emitOnBackgroundMessage:message];
|
|
25
34
|
}];
|
|
26
|
-
|
|
27
|
-
[manager startBackgroundRunnerWithEntryURL:entryURL];
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
- (void)postBackgroundMessage:(nonnull NSString *)message {
|
|
31
|
-
|
|
38
|
+
BackgroundThreadManager *manager = [BackgroundThreadManager
|
|
39
|
+
sharedInstance];
|
|
40
|
+
if (!manager.checkMessageCallback) {
|
|
41
|
+
[self bindMessageCallback];
|
|
42
|
+
}
|
|
43
|
+
[[BackgroundThreadManager sharedInstance] postBackgroundMessage:message];
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
+ (NSString *)moduleName
|
|
@@ -25,6 +25,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
25
25
|
/// @param callback The callback block to handle messages
|
|
26
26
|
- (void)setOnMessageCallback:(void (^)(NSString *message))callback;
|
|
27
27
|
|
|
28
|
+
/// Check if message callback is set
|
|
29
|
+
/// @return YES if message callback is set, NO otherwise
|
|
30
|
+
- (BOOL)checkMessageCallback;
|
|
31
|
+
|
|
28
32
|
/// Check if background runner is started
|
|
29
33
|
@property (nonatomic, readonly) BOOL isStarted;
|
|
30
34
|
|
|
@@ -89,7 +89,14 @@ static NSString *const MODULE_DEBUG_URL = @"http://localhost:8082/apps/mobile/ba
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
- (void)setOnMessageCallback:(void (^)(NSString *message))callback {
|
|
92
|
-
|
|
92
|
+
_onMessageCallback = callback;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
- (BOOL)checkMessageCallback {
|
|
96
|
+
if (self.onMessageCallback) {
|
|
97
|
+
return YES;
|
|
98
|
+
}
|
|
99
|
+
return NO;
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
@end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBackgroundThread.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBackgroundThread.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAUlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,kBAAkB,CAAC","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@ export interface Spec extends TurboModule {
|
|
|
3
3
|
readonly onBackgroundMessage: CodegenTypes.EventEmitter<string>;
|
|
4
4
|
postBackgroundMessage(message: string): void;
|
|
5
5
|
startBackgroundRunnerWithEntryURL(entryURL: string): void;
|
|
6
|
+
initBackgroundThread(): void;
|
|
6
7
|
}
|
|
7
8
|
declare const _default: Spec;
|
|
8
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeBackgroundThread.d.ts","sourceRoot":"","sources":["../../../src/NativeBackgroundThread.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,QAAQ,CAAC,mBAAmB,EAAE,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAChE,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,iCAAiC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeBackgroundThread.d.ts","sourceRoot":"","sources":["../../../src/NativeBackgroundThread.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,QAAQ,CAAC,mBAAmB,EAAE,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAChE,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,iCAAiC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1D,oBAAoB,IAAI,IAAI,CAAC;CAC9B;;AAED,wBAA0E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-background-thread",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "react-native-background-thread",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -87,10 +87,6 @@
|
|
|
87
87
|
"react": "*",
|
|
88
88
|
"react-native": "*"
|
|
89
89
|
},
|
|
90
|
-
"workspaces": [
|
|
91
|
-
"example"
|
|
92
|
-
],
|
|
93
|
-
"packageManager": "yarn@4.11.0",
|
|
94
90
|
"react-native-builder-bob": {
|
|
95
91
|
"source": "src",
|
|
96
92
|
"output": "lib",
|
|
@@ -5,6 +5,7 @@ export interface Spec extends TurboModule {
|
|
|
5
5
|
readonly onBackgroundMessage: CodegenTypes.EventEmitter<string>;
|
|
6
6
|
postBackgroundMessage(message: string): void;
|
|
7
7
|
startBackgroundRunnerWithEntryURL(entryURL: string): void;
|
|
8
|
+
initBackgroundThread(): void;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export default TurboModuleRegistry.getEnforcing<Spec>('BackgroundThread');
|