Skip to content

Commit 469f722

Browse files
committed
test: 修改call变更callAsync beta包
1 parent 2193303 commit 469f722

File tree

6 files changed

+32
-26
lines changed

6 files changed

+32
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-native-oh-tpl/async-storage",
3-
"version": "1.21.0-0.1.6",
3+
"version": "1.21.0-0.1.6-beta",
44
"private": true,
55
"workspaces": [
66
"packages/*"
Binary file not shown.

packages/default-storage/harmony/async_storage/oh-package.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"author": "",
77
"name": "@react-native-oh-tpl/async-storage",
8-
"version": "1.21.0-0.1.6",
8+
"version": "1.21.0-0.1.6-beta",
99
"description": "",
1010
"main": "ts.ts",
1111
"dependencies": {

packages/default-storage/harmony/async_storage/src/main/cpp/RNAsyncStorageTurboModule.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ using namespace rnoh;
2929
using namespace facebook;
3030

3131
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiGet(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
32-
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiGet", args, count);
32+
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "multiGet", args, count);
3333
}
3434

3535
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiSet(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
36-
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiSet", args, count);
36+
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "multiSet", args, count);
3737
}
3838

3939
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiRemove(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
40-
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiRemove", args, count);
40+
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "multiRemove", args, count);
4141
}
4242

4343
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_multiMerge(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
44-
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "multiMerge", args, count);
44+
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "multiMerge", args, count);
4545
}
4646

4747
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_getAllKeys(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
48-
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "getAllKeys", args, count);
48+
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "getAllKeys", args, count);
4949
}
5050

5151
static jsi::Value __hostFunction_RNAsyncStorageTurboModule_clear(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
52-
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "clear", args, count);
52+
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "clear", args, count);
5353
}
5454

5555
RNAsyncStorageTurboModule::RNAsyncStorageTurboModule(const ArkTSTurboModule::Context ctx, const std::string name)

packages/default-storage/harmony/async_storage/src/main/ets/AsyncStorageTurboModule.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ export class AsyncStorageTurboModule extends TurboModule {
4949
* Given an array of keys, this returns a map of (key, value) pairs for the keys found, and
5050
* (key, null) for the keys that haven't been found.
5151
*/
52-
multiGet(keys: string[], callback: (error?: Object, result?: [string, string][] | null) => void) {
52+
multiGet(keys: string[], callback: (error?: Object, result?: [string, string][] | null) => void): Promise<void> {
5353
Logger.debug(CommonConstants.TAG, `Module multiGet() Call!`);
5454
this.runMultiGet(keys).then((result) => { callback(result[0], result[1]) }).catch((e: Error) => {
5555
Logger.debug(CommonConstants.TAG, `Module multiGet() Call Fail!${e.message}`);
5656
})
5757
Logger.debug(CommonConstants.TAG, `Module multiGet() End!`);
58+
return Promise.resolve();
5859
}
5960

6061
async runMultiGet(keys: string[]): Promise<[Object, [string, string][] | null]> {
@@ -129,12 +130,13 @@ export class AsyncStorageTurboModule extends TurboModule {
129130
* return AsyncLocalStorageFailure, but all other pairs will have been inserted.
130131
* The insertion will replace conflicting (key, value) pairs.
131132
*/
132-
multiSet(keyValueArray: [string, string][], callback: (error?: Object) => void) {
133+
multiSet(keyValueArray: [string, string][], callback: (error?: Object) => void): Promise<void> {
133134
Logger.debug(CommonConstants.TAG, `Module multiSet() Call!`);
134135
this.runMultiSet(keyValueArray).then((error) => { callback(error) }).catch((e: Error) => {
135136
Logger.debug(CommonConstants.TAG, `Module multiSet() Call Fail!${e.message}`);
136137
})
137138
Logger.debug(CommonConstants.TAG, `Module multiSet() End!`);
139+
return Promise.resolve();
138140
}
139141

140142
async runMultiSet(keyValueArray: [string, string][], hasError = false): Promise<Object> {
@@ -200,7 +202,7 @@ export class AsyncStorageTurboModule extends TurboModule {
200202
}
201203
}
202204
}
203-
if(error !== null) {
205+
if (error !== null) {
204206
return error;
205207
} else {
206208
return null;
@@ -210,12 +212,13 @@ export class AsyncStorageTurboModule extends TurboModule {
210212
/**
211213
* Removes all rows of the keys given.
212214
*/
213-
multiRemove(keys: string[], callback: (error?:Object) => void) {
215+
multiRemove(keys: string[], callback: (error?: Object) => void): Promise<void> {
214216
Logger.debug(CommonConstants.TAG, `Module multiRemove() Call!`);
215-
this.runMultiRemove(keys).then((error)=>{callback(error)}).catch((e:Error)=>{
217+
this.runMultiRemove(keys).then((error) => { callback(error) }).catch((e: Error) => {
216218
Logger.debug(CommonConstants.TAG, `Module multiRemove() Call Fail!${e.message}`);
217219
})
218220
Logger.debug(CommonConstants.TAG, `Module multiRemove() End!`);
221+
return Promise.resolve();
219222
}
220223

221224
async runMultiRemove(keys: string[]): Promise<Object> {
@@ -237,7 +240,7 @@ export class AsyncStorageTurboModule extends TurboModule {
237240

238241
async asyncMultiRemove(keys: string[]): Promise<Object> {
239242
Logger.debug(CommonConstants.TAG, `ModuleSub asyncMultiRemove() Call!`);
240-
if(keys.length === 0) {
243+
if (keys.length === 0) {
241244
return null;
242245
}
243246
if (!await this.table.ensureDatabase(this.ctx.uiAbilityContext)) {
@@ -269,12 +272,13 @@ export class AsyncStorageTurboModule extends TurboModule {
269272
* Given an array of (key, value) pairs, this will merge the given values with the stored values
270273
* of the given keys, if they exist.
271274
*/
272-
multiMerge(keyValueArray: [string, string][], callback: (error?: Object) => void) {
275+
multiMerge(keyValueArray: [string, string][], callback: (error?: Object) => void): Promise<void> {
273276
Logger.debug(CommonConstants.TAG, `Module multiMerge() Call!`);
274-
this.runMultiMerge(keyValueArray).then((error)=>{callback(error)}).catch((e:Error)=>{
277+
this.runMultiMerge(keyValueArray).then((error) => { callback(error) }).catch((e: Error) => {
275278
Logger.debug(CommonConstants.TAG, `Module multiMerge() Call Fail!${e.message}`);
276279
})
277280
Logger.debug(CommonConstants.TAG, `Module multiMerge() End!`);
281+
return Promise.resolve();
278282
}
279283

280284
async runMultiMerge(keyValueArray: [string, string][]): Promise<Object> {
@@ -314,16 +318,16 @@ export class AsyncStorageTurboModule extends TurboModule {
314318
error = AsyncStorageErrorUtil.getInvalidValueError(null)
315319
return error;
316320
}
317-
if(!await AsyncLocalStorageUtil.mergeImpl(this.table.rdbStore, keyValueArray[idx][0], keyValueArray[idx][1])){
321+
if (!await AsyncLocalStorageUtil.mergeImpl(this.table.rdbStore, keyValueArray[idx][0], keyValueArray[idx][1])) {
318322
error = AsyncStorageErrorUtil.getDBError(null)
319323
return error;
320324
}
321325
}
322326
} catch (e) {
323327
Logger.warn(CommonConstants.TAG, e.message);
324328
error = AsyncStorageErrorUtil.getError(null, e.message);
325-
}
326-
if(error != null) {
329+
}
330+
if (error != null) {
327331
return error;
328332
} else {
329333
return null;
@@ -333,12 +337,13 @@ export class AsyncStorageTurboModule extends TurboModule {
333337
/**
334338
* Clears the database.
335339
*/
336-
clear(callback: (error?: Object) => void) {
340+
clear(callback: (error?: Object) => void): Promise<void> {
337341
Logger.debug(CommonConstants.TAG, `Module clear() Call!`);
338-
this.runClear().then((error)=>{callback(error)}).catch((e:Error)=>{
342+
this.runClear().then((error) => { callback(error) }).catch((e: Error) => {
339343
Logger.debug(CommonConstants.TAG, `Module clear() Call Fail!${e.message}`);
340344
})
341345
Logger.debug(CommonConstants.TAG, `Module clear() End!`);
346+
return Promise.resolve();
342347
}
343348

344349
async runClear(): Promise<Object> {
@@ -375,12 +380,13 @@ export class AsyncStorageTurboModule extends TurboModule {
375380
/**
376381
* Returns an array with all keys from the database.
377382
*/
378-
getAllKeys(callback: (error?: Object, result?: string[] | null) => void) {
383+
getAllKeys(callback: (error?: Object, result?: string[] | null) => void): Promise<void> {
379384
Logger.debug(CommonConstants.TAG, `Module getAllKeys() Call!`);
380-
this.runGetAllKeys().then((result)=>{callback(result[0], result[1])}).catch((e:Error)=>{
385+
this.runGetAllKeys().then((result) => { callback(result[0], result[1]) }).catch((e: Error) => {
381386
Logger.debug(CommonConstants.TAG, `Module getAllKeys() Call Fail!${e.message}`);
382387
})
383388
Logger.debug(CommonConstants.TAG, `Module getAllKeys() End!`);
389+
return Promise.resolve();
384390
}
385391

386392
async runGetAllKeys(): Promise<[Object, string[] | null]> {
@@ -410,14 +416,14 @@ export class AsyncStorageTurboModule extends TurboModule {
410416
predicates.isNotNull(ReactDatabaseSupplier.KEY_COLUMN);
411417
let cursor = await this.table.rdbStore.query(predicates);
412418
try {
413-
if(cursor.goToFirstRow()){
419+
if (cursor.goToFirstRow()) {
414420
do {
415421
data.push(cursor.getString(cursor.getColumnIndex('KEY')));
416422
} while (cursor.goToNextRow())
417423
}
418424
} catch (e) {
419425
Logger.warn(CommonConstants.TAG, `Module GetAllKeys() error: ${e.message}`);
420-
return [AsyncStorageErrorUtil.getError(null, e.message),null];
426+
return [AsyncStorageErrorUtil.getError(null, e.message), null];
421427
} finally {
422428
cursor.close();
423429
}

packages/default-storage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-native-oh-tpl/async-storage",
3-
"version": "1.21.0-0.1.6",
3+
"version": "1.21.0-0.1.6-beta",
44
"description": "Asynchronous, persistent, key-value storage system for React Native.",
55
"main": "lib/commonjs/index.js",
66
"module": "lib/module/index.js",

0 commit comments

Comments
 (0)