Skip to Content
微前端设计与实现
book

微前端设计与实现

by Luca Mezzalira
August 2022
Beginner to intermediate
270 pages
7h 38m
Chinese
Posts & Telecom Press
Content preview from 微前端设计与实现
112
5
开发人员使用正确的格式来通信或监听应用中的事件:
const PaymentEvents = {
PAYMENT_CHANGED: "paymentMethodChanged";
// 其他事件
}
之后,可以冻结对象,防止运行时更改对象结构、添加或删除对象的属性。
当在同一个视图中有多个微前端通过事件相互通信时,我们必须确保所有事件都被相关的
微前端捕获。假设在同一个视图中有
3
个微前端
,其中两个立即加载,而第
3
个由于网络
问题需要等待一段时间。当前两个微前端发出事件时,第
3
个微前端在加载时无法捕获发
生的任何事件。一种可能的解决方案是在应用容器中创建一个事件缓冲区,并在第
3
个微
前端完全加载时重放它们。这个事件缓冲区用于监控每个微前端的状态,将所有事件收集
到一个数组或类似的数据结构中,然后将所有事件按需重放给一个或多个微前端,而不是
把事件列表中的全部事件重放给每个微前端(这样做可能会导致内部状态不匹配)。在同
一个视图中有多个微前端时,需要认真思考如何处理故障或部分故障的状态。虽然很烦
琐,但我们必须考虑这些情况,因为正如
AW
S
CTO Werner Vogels
所说,“不要心存侥
幸,失败随时都在”。
5.4
 项目演变
我们不想创建一个只能在短期内运转的项目,而是希望创建一个可以随着时间的推移长
期运行的产品。当组织目标发生变化时,开发团队无须从头再来。那么,让我们一起探
讨一下如何让这个项目长期发展,以及我们如何在不同的子域之间创建一个连贯、一致
的实现。
5.4.1
 嵌入旧版应用 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python语言及其应用(第2版)

Python语言及其应用(第2版)

Bill Lubanovic

Publisher Resources

ISBN: 9787115595089