Skip to content

Commit

Permalink
feat(react,vue): perf startBatch
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomchan-cxj committed Jan 14, 2022
1 parent d586186 commit 2c61603
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 15 deletions.
3 changes: 3 additions & 0 deletions framework/js/packages/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ declare namespace HippyTypes {
declare type Diff<T extends keyof any, U extends keyof any> =
({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];
declare type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;

declare const __PLATFORM__: HippyTypes.Platform;

/* eslint-disable */
// @ts-ignore
declare var global: HippyTypes.HippyGlobal & typeof globalThis;
3 changes: 0 additions & 3 deletions framework/js/packages/hippy-react/src/color/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import baseColor from './color-parser';

type Color = string | number;

// eslint-disable-next-line no-underscore-dangle
declare const __PLATFORM__: HippyTypes.Platform;

interface ColorParserOption {
platform?: HippyTypes.Platform
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class AnimationSet implements AnimationSet {
// Set as iOS default
let animationEventName = 'onAnimation';
// If running in Android, change it.
// @ts-ignore
if (__PLATFORM__ === 'android' || Device.platform.OS === 'android') {
animationEventName = 'onHippyAnimation';
}
Expand Down
1 change: 0 additions & 1 deletion framework/js/packages/hippy-react/src/modules/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class Animation implements Animation {
// Set as iOS default
let animationEventName = 'onAnimation';
// If running in Android, change it.
// @ts-ignore
if (__PLATFORM__ === 'android' || Device.platform.OS === 'android') {
animationEventName = 'onHippyAnimation';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const fakeBackAndroid = {
};

const BackAndroid = (() => {
// @ts-ignore
if (__PLATFORM__ === 'android' || Device.platform.OS === 'android') {
realBackAndroid.initEventListener();
return realBackAndroid;
Expand Down
4 changes: 0 additions & 4 deletions framework/js/packages/hippy-react/src/renderer/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ function batchUpdate(rootViewId: number): void {
break;
case NODE_OPERATION_TYPES.updateNode:
trace(...componentName, 'updateNode', chunk.nodes);
// FIXME: iOS should be able to update multiple nodes at once.
// @ts-ignore
if (__PLATFORM__ === 'ios' || Device.platform.OS === 'ios') {
chunk.nodes.forEach(node => (
UIManagerModule.updateNode(rootViewId, [node])
Expand All @@ -94,8 +92,6 @@ function batchUpdate(rootViewId: number): void {
break;
case NODE_OPERATION_TYPES.deleteNode:
trace(...componentName, 'deleteNode', chunk.nodes);
// FIXME: iOS should be able to delete mutiple nodes at once.
// @ts-ignore
if (__PLATFORM__ === 'ios' || Device.platform.OS === 'ios') {
chunk.nodes.forEach(node => (
UIManagerModule.deleteNode(rootViewId, [node])
Expand Down
9 changes: 4 additions & 5 deletions framework/js/packages/hippy-vue/src/renderer/native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ function chunkNodes(batchNodes) {
let __cssMap;

function endBatch(app) {
if (!__batchIdle) {
if (!__batchIdle) return;
__batchIdle = false;
if (__batchNodes.length === 0) {
__batchIdle = true;
return;
}
__batchIdle = false;
const {
$nextTick,
$options: {
rootViewId,
},
} = app;

$nextTick(() => {
const chunks = chunkNodes(__batchNodes);
chunks.forEach((chunk) => {
Expand All @@ -106,7 +107,6 @@ function endBatch(app) {
break;
case NODE_OPERATION_TYPES.updateNode:
trace(...componentName, 'updateNode', chunk.nodes);
// FIXME: iOS should be able to update multiple nodes at once.
if (__PLATFORM__ === 'ios' || Native.Platform === 'ios') {
chunk.nodes.forEach(node => (
UIManagerModule.updateNode(rootViewId, [node])
Expand All @@ -117,7 +117,6 @@ function endBatch(app) {
break;
case NODE_OPERATION_TYPES.deleteNode:
trace(...componentName, 'deleteNode', chunk.nodes);
// FIXME: iOS should be able to delete mutiple nodes at once.
if (__PLATFORM__ === 'ios' || Native.Platform === 'ios') {
chunk.nodes.forEach(node => (
UIManagerModule.deleteNode(rootViewId, [node])
Expand Down

0 comments on commit 2c61603

Please sign in to comment.