[英]Front end “micro services” with Angular 2
I'm looking for a solution for a bit of an odd situation. 我正在寻找一个奇怪的情况的解决方案。 Let's take a quick look at the angular2-seed project so I can better explain: https://github.com/mgechev/angular2-seed/tree/master/src/client/app . 让我们快速浏览angular2-seed项目,以便更好地解释: https : //github.com/mgechev/angular2-seed/tree/master/src/client/app 。
In that project, we have 3 isolated modules - about, home, shared. 在该项目中,我们有3个独立的模块 - 关于,家庭,共享。 What I am looking for is a way to isolate development of these, so we're ultimately able to release each piece independently. 我正在寻找的是一种隔离这些发展的方法,因此我们最终能够独立发布每一部分。 For example, say Team A is working on the about section, and Team B is working on home. 例如,假设A队正在研究关于部分,而B队正在家中工作。 Work is complete for each, and we're ready to release, however we realize the about section is missing a critical piece of functionality, however we still want to release the change to the home section. 每个工作都已完成,我们已准备好发布,但是我们发现about部分缺少一个关键功能,但我们仍然希望将更改发布到主页部分。 What we're looking for is a way to achieve this. 我们正在寻找的是一种实现这一目标的方法。
Here are some solutions already explored, but I'm not really happy with: 以下是一些已经探索过的解决方案,但我并不满意:
Orchestration: 业务流程:
Have each team build a component library (NPM) and pull those into a single Angular 2 application. 让每个团队构建一个组件库(NPM)并将它们放入一个Angular 2应用程序中。 That way, the teams can develop using microservices principles , but you can deploy a SPA monolith which reduces complexity. 这样,团队可以使用微服务原则进行开发,但您可以部署SPA 整体 ,从而降低复杂性。
Large component libraries should have multiple bundles and modules so you can be selective about what you pull in. 大型组件库应该有多个软件包和模块,因此您可以选择引入的内容。
Communication between microservices: 微服务之间的通信:
If necessary, the component libraries can communicate over a back-end message bus. 如有必要,组件库可以通过后端消息总线进行通信。
If direct client-side integration is required between the component libraries, then you need a 3rd component library that about
and home
depends on, which contains a light-weight injectable message/event service. 如果组件库之间需要直接的客户端集成,那么您需要一个about
和home
依赖的第三个组件库,它包含一个轻量级的可注入消息/事件服务。 You can implement that service using RxJS Subjects . 您可以使用RxJS主题实现该服务。
A javascript meta-framework could work for you. 一个javascript元框架可以为你工作。 Here this interesting project It takes inspiration from React component lifecycles by applying lifecycles to entire applications. 这个有趣的项目通过将生命周期应用于整个应用程序,它从React组件生命周期中获取灵感。
Some features: 一些功能:
I hope it helps you to go in the right direction. 我希望它能帮助你朝着正确的方向前进。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.