Skip to content

Commit bfd5967

Browse files
committed
deprecate some rnoh api
1 parent f9014a4 commit bfd5967

12 files changed

Lines changed: 54 additions & 44 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { RNPackageContext, RNPackage } from '@rnoh/react-native-openharmony';
2+
import PushyPackage from 'pushy';
3+
4+
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
5+
return [new PushyPackage(ctx)];
6+
}

Example/harmony_use_pushy/harmony/entry/src/main/ets/RNPackagesFactory.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import {RNAbility} from '@rnoh/react-native-openharmony';
22

33
export default class EntryAbility extends RNAbility {
4-
getPagePath() {
4+
override getPagePath() {
55
return 'pages/Index';
66
}
7-
8-
shouldCleanUpRNInstance__hack() {
9-
return true // Used by RNOH devs. If set to true, the app may crash.
10-
}
117
}

Example/harmony_use_pushy/harmony/entry/src/main/ets/pages/Index.ets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PushyFileJSBundleProvider } from 'pushy/src/main/ets/PushyFileJSBundleProvider';
1+
import { PushyFileJSBundleProvider } from 'pushy';
22
import { ComponentBuilderContext, RNOHCoreContext,RNAbility,
33
MetroJSBundleProvider } from '@rnoh/react-native-openharmony';
44
import {

harmony/pushy/index.ets

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
2-
export * from './ts'
1+
export { PushyPackage as default } from './src/main/ets/PushyPackage';
2+
export { PushyPackage } from './src/main/ets/PushyPackage';
3+
export { PushyTurboModule } from './src/main/ets/PushyTurboModule';
4+
export { PushyFileJSBundleProvider } from './src/main/ets/PushyFileJSBundleProvider';

harmony/pushy/oh-package-lock.json5

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
RNOHPackage,
3+
UITurboModule,
4+
UITurboModuleContext,
5+
} from '@rnoh/react-native-openharmony';
6+
import { PushyTurboModule } from './PushyTurboModule';
7+
8+
export class PushyPackage extends RNOHPackage {
9+
override getUITurboModuleFactoryByNameMap(): Map<
10+
string,
11+
(ctx: UITurboModuleContext) => UITurboModule | null
12+
> {
13+
return new Map<string, (ctx: UITurboModuleContext) => UITurboModule>()
14+
.set(PushyTurboModule.NAME, (ctx) => new PushyTurboModule(ctx));
15+
}
16+
}

harmony/pushy/src/main/ets/PushyPackage.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
RNPackage,
3+
UITurboModule,
4+
UITurboModuleContext,
5+
} from '@rnoh/react-native-openharmony/ts';
6+
import { PushyTurboModule } from './PushyTurboModule';
7+
8+
export class PushyPackage extends RNPackage {
9+
override getUITurboModuleFactoryByNameMap(): Map<
10+
string,
11+
(ctx: UITurboModuleContext) => UITurboModule | null
12+
> {
13+
return new Map<string, (ctx: UITurboModuleContext) => UITurboModule>()
14+
.set(PushyTurboModule.NAME, (ctx) => new PushyTurboModule(ctx));
15+
}
16+
}

harmony/pushy/src/main/ets/PushyTurboModule.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
TurboModule,
3-
TurboModuleContext,
2+
UITurboModule,
3+
UITurboModuleContext,
44
} from '@rnoh/react-native-openharmony/ts';
55
import common from '@ohos.app.ability.common';
66
import { bundleManager } from '@kit.AbilityKit';
@@ -12,11 +12,13 @@ import { util } from '@kit.ArkTS';
1212

1313
const TAG = 'PushyTurboModule';
1414

15-
export class PushyTurboModule extends TurboModule {
15+
export class PushyTurboModule extends UITurboModule {
16+
public static readonly NAME = 'Pushy';
17+
1618
mUiCtx: common.UIAbilityContext;
1719
context: UpdateContext;
1820

19-
constructor(protected ctx: TurboModuleContext) {
21+
constructor(protected ctx: UITurboModuleContext) {
2022
super(ctx);
2123
logger.debug(TAG, ',PushyTurboModule constructor');
2224
this.mUiCtx = ctx.uiAbilityContext;

0 commit comments

Comments
 (0)