Skip to content
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

feat: support rax-componentwrapper #219

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

cryzzchen
Copy link
Contributor

@cryzzchen cryzzchen commented Sep 13, 2021

rax-componentwrapper: raxjs/rax-components#399

在运行时小程序中,默认所有的数据更新都使用 PagesetData 方法。对于部分需要频繁更新数据的元素来说,可以在元素外包裹 rax-componentwrapper 的方式,自动将该元素转成自定义组件,当元素数据发生变化时,使用组件的 setData,来起到性能优化的目的。

需要注意:在阿里小程序中,需要开启基础库 2.0 构建或开启 component2 功能时,才能正常使用该组件,否则将降级使用 PagesetData 方法。

@cryzzchen cryzzchen changed the title Feature/component wrapper feat: support rax-componentwrapper Sep 24, 2021
@@ -0,0 +1,4 @@
module.exports = {
WrapperPackage: 'rax-componentwrapper',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个名字要不要再考虑下

Comment on lines +171 to 198
if (rootStacks.length > 0) {
if (internal.$batchedUpdates) {
internal.firstRenderCallback();
this._batchedUpdate(internal, internal, rootStacks, callback);
} else {
const renderObject = Object.create(null);
rootStacks.forEach((task) => {
renderObject[task.path] = isFunction(task.value) ? task.value() : task.value;
});
internal.firstRenderCallback(renderObject);
internal.setData(renderObject, callback);
}
}

if (componentWrapperCount > 0) {
Object.values(componentWrapperObject).forEach(({ node, data }) => {
if (internal.$batchedUpdates) {
internal.firstRenderCallback();
this._batchedUpdate(internal, node._internal, data, callback);
} else {
const renderObject = Object.create(null);
data.forEach((task) => {
renderObject[task.path] = isFunction(task.value) ? task.value() : task.value;
});
internal.firstRenderCallback(renderObject);
node._internal.setData(renderObject, callback);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码里面的逻辑可以抽离出来


function ensureWrapperFolder() {

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有个空函数

@@ -1,6 +1,6 @@
{
"name": "miniapp-runtime-config",
"version": "0.3.9",
"version": "0.3.10-2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

版本号

Comment on lines +27 to +31
"miniapp-builder-shared": "beta",
"rax-miniapp-babel-plugins": "beta",
"rax-miniapp-config-webpack-plugin": "^2.0.0",
"rax-miniapp-runtime-webpack-plugin": "^4.0.0",
"miniapp-render": "^2.0.0"
"rax-miniapp-runtime-webpack-plugin": "beta",
"miniapp-render": "beta"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

版本号

@@ -1,6 +1,6 @@
{
"name": "rax-miniapp-babel-plugins",
"version": "0.1.15",
"version": "0.1.16-3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@@ -22,6 +22,6 @@
"@babel/code-frame": "^7.8.3",
"fs-extra": "^9.0.1",
"md5": "^2.2.1",
"miniapp-builder-shared": "^0.2.0"
"miniapp-builder-shared": "0.2.11-0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@@ -21,12 +21,15 @@
"csso": "^4.0.3",
"fs-extra": "^8.1.0",
"lodash.isequal": "^4.5.0",
"miniapp-builder-shared": "^0.2.0",
"miniapp-builder-shared": "0.2.11-0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@@ -58,6 +62,7 @@ class MiniAppRuntimePlugin {
let isFirstRender = true;
let lastUsingComponents = {};
let lastUsingPlugins = {};
let lastImportComponentWrapper = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于 lastUsingXXX 这里之前的逻辑写的有点混乱,看看能否重构一下,或者多验证一下。主要是 npm run start 的时候用户修改代码时能确保正常运行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants