Skip to content

Commit

Permalink
fix(vue): remove redundant props & perf cache logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomchan-cxj authored and zealotchen0 committed May 25, 2023
1 parent 42d4357 commit d635977
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 40 deletions.
37 changes: 0 additions & 37 deletions examples/hippy-vue-next-demo/src/main-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,43 +93,6 @@ const initCallback = ({ superProps, rootViewId }) => {
// // mount app
// app.mount('#root');
// });

// invoke custom native apis with type hints
Native.callNative('customModule', 'customMethod', '123', 456);
Native.callNativeWithPromise(
'customModule',
'customMethodWithPromise',
'123',
456,
).then((result) => {
console.log(result);
});

// register custom component with type inference
registerElement('customComponent', {
component: {
name: 'custom-component',
processEventData(
evtData: EventsUnionType,
nativeEventParams: { [key: string]: NeedToTyped },
) {
const { handler: event, __evt: nativeEventName } = evtData;

switch (nativeEventName) {
// this can infer event is HippyTouchEvent from type narrowing
case 'onTest':
event.contentOffset = nativeEventParams.position;
break;
// extended HippyEvent which has testProp
case 'onAnotherTest':
event.testProp = 123;
break;
default:
}
return event;
},
},
});
};

// start hippy app
Expand Down
1 change: 0 additions & 1 deletion packages/hippy-vue-next/src/native-component/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ export function registerAnimation(vueApp: App): void {
useAnimation: true,
style: this.style,
tag: this.$props.tag,
playing: this.$props.playing,
...this.$props.props,
},
this.$slots.default ? this.$slots.default() : null,
Expand Down
1 change: 0 additions & 1 deletion packages/hippy-vue-next/src/native-component/swiper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export function registerSwiper(vueApp: App): void {
...on,
ref: 'swiper',
initialPage: this.$initialSlide,
...this.$props,
},
this.$slots.default ? this.$slots.default() : null,
);
Expand Down
3 changes: 2 additions & 1 deletion packages/hippy-vue-next/src/runtime/node/hippy-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export class HippyNode extends HippyEventTarget {

// if the root node is not rendered on the screen, start rendering from the root node first
// render the child node if the child node is not rendered
renderInsertChildNativeNode(parentNode.convertToNativeNodes(true));
const nodeList = parentNode.convertToNativeNodes(true);
// update the isMounted flag
parentNode.eachNode((rawNode: HippyNode) => {
const node = rawNode;
Expand All @@ -441,6 +441,7 @@ export class HippyNode extends HippyEventTarget {
// cache the nodes inserted into the native to improve the search speed
preCacheNode(node, node.nodeId);
});
renderInsertChildNativeNode(nodeList);
}
}

Expand Down

0 comments on commit d635977

Please sign in to comment.