feat:add pureCallEntityMethod,avoid hook affects

This commit is contained in:
pengfei.zhou
2021-04-14 16:53:38 +08:00
committed by osborn
parent b762b9db4b
commit 009e8734b6
37 changed files with 266 additions and 209 deletions

View File

@@ -2032,7 +2032,6 @@ var List = /** @class */ (function (_super) {
function List() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map;
_this.ignoreDirtyCallOnce = false;
_this.itemCount = 0;
_this.batchCount = 15;
return _this;
@@ -2059,17 +2058,8 @@ var List = /** @class */ (function (_super) {
this.cachedViews.set("" + itemIdx, view);
return view;
};
List.prototype.isDirty = function () {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return _super.prototype.isDirty.call(this);
};
List.prototype.renderBunchedItems = function (start, length) {
var _this = this;
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map(function (_, idx) {
var listItem = _this.getItem(start + idx);
return listItem.toModel();
@@ -2185,7 +2175,6 @@ var Slider = /** @class */ (function (_super) {
function Slider() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map;
_this.ignoreDirtyCallOnce = false;
_this.itemCount = 0;
_this.batchCount = 3;
return _this;
@@ -2199,17 +2188,8 @@ var Slider = /** @class */ (function (_super) {
this.cachedViews.set("" + itemIdx, view);
return view;
};
Slider.prototype.isDirty = function () {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return _super.prototype.isDirty.call(this);
};
Slider.prototype.renderBunchedItems = function (start, length) {
var _this = this;
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map(function (_, idx) {
var slideItem = _this.getItem(start + idx);
return slideItem.toModel();
@@ -2560,7 +2540,6 @@ var FlowLayout = /** @class */ (function (_super) {
function FlowLayout() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map;
_this.ignoreDirtyCallOnce = false;
_this.columnCount = 2;
_this.itemCount = 0;
_this.batchCount = 15;
@@ -2584,17 +2563,8 @@ var FlowLayout = /** @class */ (function (_super) {
this.cachedViews.set("" + itemIdx, view);
return view;
};
FlowLayout.prototype.isDirty = function () {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return _super.prototype.isDirty.call(this);
};
FlowLayout.prototype.renderBunchedItems = function (start, length) {
var _this = this;
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map(function (_, idx) {
var listItem = _this.getItem(start + idx);
return listItem.toModel();

View File

@@ -1531,7 +1531,6 @@ class List extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0;
this.batchCount = 15;
}
@@ -1557,16 +1556,7 @@ class List extends Superview {
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx);
return listItem.toModel();
@@ -1660,7 +1650,6 @@ class Slider extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0;
this.batchCount = 3;
}
@@ -1673,16 +1662,7 @@ class Slider extends Superview {
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx);
return slideItem.toModel();
@@ -1948,7 +1928,6 @@ class FlowLayout extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.columnCount = 2;
this.itemCount = 0;
this.batchCount = 15;
@@ -1971,16 +1950,7 @@ class FlowLayout extends Superview {
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx);
return listItem.toModel();

View File

@@ -1398,6 +1398,29 @@ var doric = (function (exports) {
loge("Cannot find method for context id:" + contextId + ",method name is:" + methodName);
}
}
function pureCallEntityMethod(contextId, methodName, args) {
var arguments$1 = arguments;
var context = gContexts.get(contextId);
if (context === undefined) {
loge("Cannot find context for context id:" + contextId);
return;
}
if (context.entity === undefined) {
loge("Cannot find holder for context id:" + contextId);
return;
}
if (Reflect.has(context.entity, methodName)) {
var argumentsList = [];
for (var i = 2; i < arguments.length; i++) {
argumentsList.push(arguments$1[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge("Cannot find method for context id:" + contextId + ",method name is:" + methodName);
}
}
function jsObtainEntry(contextId) {
var context = jsObtainContext(contextId);
var exportFunc = function (constructor) {
@@ -13775,6 +13798,7 @@ var doric = (function (exports) {
exports.jsObtainEntry = jsObtainEntry;
exports.jsRegisterModule = jsRegisterModule;
exports.jsReleaseContext = jsReleaseContext;
exports.pureCallEntityMethod = pureCallEntityMethod;
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -1397,6 +1397,27 @@ var doric = (function (exports) {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
function pureCallEntityMethod(contextId, methodName, args) {
const context = gContexts.get(contextId);
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`);
return;
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`);
return;
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList = [];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId);
const exportFunc = (constructor) => {
@@ -1538,6 +1559,7 @@ var doric = (function (exports) {
exports.jsObtainEntry = jsObtainEntry;
exports.jsRegisterModule = jsRegisterModule;
exports.jsReleaseContext = jsReleaseContext;
exports.pureCallEntityMethod = pureCallEntityMethod;
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -1426,6 +1426,27 @@ function jsCallEntityMethod(contextId, methodName, args) {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
function pureCallEntityMethod(contextId, methodName, args) {
const context = gContexts.get(contextId);
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`);
return;
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`);
return;
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList = [];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId);
const exportFunc = (constructor) => {
@@ -1567,6 +1588,7 @@ var doric = /*#__PURE__*/Object.freeze({
__require__: __require__,
jsRegisterModule: jsRegisterModule,
jsCallEntityMethod: jsCallEntityMethod,
pureCallEntityMethod: pureCallEntityMethod,
jsObtainEntry: jsObtainEntry,
jsCallbackTimer: jsCallbackTimer
});
@@ -3030,7 +3052,6 @@ class List extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0;
this.batchCount = 15;
}
@@ -3056,16 +3077,7 @@ class List extends Superview {
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx);
return listItem.toModel();
@@ -3159,7 +3171,6 @@ class Slider extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0;
this.batchCount = 3;
}
@@ -3172,16 +3183,7 @@ class Slider extends Superview {
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx);
return slideItem.toModel();
@@ -3447,7 +3449,6 @@ class FlowLayout extends Superview {
constructor() {
super(...arguments);
this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.columnCount = 2;
this.itemCount = 0;
this.batchCount = 15;
@@ -3470,16 +3471,7 @@ class FlowLayout extends Superview {
this.cachedViews.set(`${itemIdx}`, view);
return view;
}
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx);
return listItem.toModel();