Skip to content

feat: 适配支持worker turbo module #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified packages/default-storage/harmony/async_storage.har
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
* SOFTWARE.
*/

import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
import { RNPackage, AnyThreadTurboModuleFactory } from '@rnoh/react-native-openharmony/ts';
import type { AnyThreadTurboModule, AnyThreadTurboModuleContext } from '@rnoh/react-native-openharmony/ts';
import { AsyncStorageTurboModule } from './AsyncStorageTurboModule';

class AsyncStorageTurboModulesFactory extends TurboModulesFactory {
class AsyncStorageTurboModulesFactory extends AnyThreadTurboModuleFactory {

createTurboModule(name: string): TurboModule | null {
createTurboModule(name: string): AnyThreadTurboModule | null {
if (name === 'RNCAsyncStorage') {
return new AsyncStorageTurboModule(this.ctx);
}
Expand All @@ -41,7 +41,7 @@ class AsyncStorageTurboModulesFactory extends TurboModulesFactory {
}

export class AsyncStoragePackage extends RNPackage {
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
createAnyThreadTurboModuleFactory(ctx: AnyThreadTurboModuleContext): AnyThreadTurboModuleFactory {
return new AsyncStorageTurboModulesFactory(ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
* SOFTWARE.
*/

import relationalStore from '@ohos.data.relationalStore'
import taskpool from '@ohos.taskpool';
import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
import relationalStore from '@ohos.data.relationalStore';
import { AnyThreadTurboModule, AnyThreadTurboModuleContext } from '@rnoh/react-native-openharmony/ts';
import ReactDatabaseSupplier from './ReactDatabaseSupplier';
import AsyncStorageErrorUtil from './AsyncStorageErrorUtil';
import Logger from './Logger';
Expand All @@ -34,12 +33,12 @@ import AsyncLocker from './AsyncLocker'

const MAX_SQL_KEYS = 999;

export class AsyncStorageTurboModule extends TurboModule {
export class AsyncStorageTurboModule extends AnyThreadTurboModule {

private table = new ReactDatabaseSupplier()
private lock: AsyncLocker = new AsyncLocker()

constructor(ctx: TurboModuleContext) {
constructor(ctx: AnyThreadTurboModuleContext) {
super(ctx);
Logger.debug(CommonConstants.TAG, `AsyncStorageTurboModule construct!`);
this.table.initialRdbStore(this.ctx.uiAbilityContext);
Expand Down
Loading