alibaba / ice

🚀 ice.js: The Progressive App Framework Based On React(基于 React 的渐进式应用框架)
https://ice.work
MIT License
17.83k stars 2.09k forks source link

feat: 新增触发重新渲染事件ICE_RERENDER #6919

Closed bloody-ux closed 3 months ago

bloody-ux commented 3 months ago

当前stream-error插件能够解决正常加载ice相关js的场景(通过script标签加载)。 但很多场景下,为了更好地渲染性能,业务测会通过createElement('script')方式异步加载ice的js, 这种情况下,很大概率load事件的触发会比 ice相关js加载完成更早完成,此时就没有办法做兜底rerender了。

PR中,新增一个window事件ICE_RERENDER,业务测在通过createElement('script')加载完成之后,dispatch一个ICE_RERENDER事件到window上,进行触发。

同时为了避免race condition,在PR中新增了hasRendered状态位,保证最多只会被触发一次。

版本号和Changelog的变更,请@ClarkXia帮忙变更

CLAassistant commented 3 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


那达 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.