前端“微服务”与Angular 2 [英] Front end "micro services" with Angular 2

查看:179
本文介绍了前端“微服务”与Angular 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个有点奇怪情况的解决方案。让我们快速浏览angular2-seed项目,这样我就可以更好地解释: https://github.com/mgechev/angular2-seed/tree/master/src/client/app

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.

在该项目中,我们有3个孤立的模块 - 关于,家庭,共享。我正在寻找的是一种隔离这些发展的方法,因此我们最终能够独立发布每一部分。例如,假设A队正在研究关于部分,而B队正在家中工作。每个工作都已完成,我们已准备好发布,但是我们发现about部分缺少一个关键功能,但我们仍然希望将更改发布到主页部分。我们正在寻找的是一种实现这一目标的方法。

In that project, we have 3 isolated modules - about, home, shared. 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. 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. What we're looking for is a way to achieve this.

以下是一些已经探索过的解决方案,但我对此并不满意:

Here are some solutions already explored, but I'm not really happy with:


  • 对于家庭/约有完全不同的应用程序(在我看来,这消除了SPA的许多好处)。

  • 让每个模块(关于,家庭,共享)汇总到它自己的NPM包中。当我们去部署时,我们可以通过某种方式协调拉出这些模块的所有已发布的NPM包。

推荐答案

协调:

让每个团队构建一个组件库(NPM)并将它们放入一个Angular 2应用程序中。这样,团队可以使用微服务原则进行开发,但您可以部署SPA 整体降低了复杂性。

Have each team build a component library (NPM) and pull those into a single Angular 2 application. That way, the teams can develop using microservices principles, but you can deploy a SPA monolith which reduces complexity.

大型组件库应该有多个软件包和模块,这样您就可以选择自己引入的内容。

Large component libraries should have multiple bundles and modules so you can be selective about what you pull in.

微服务之间的通信:

如有必要,组件库可以通过后端消息总线进行通信。

If necessary, the component libraries can communicate over a back-end message bus.

如果组件库之间需要直接客户端集成,那么你需要一个关于的第三个组件库和 home 取决于,它包含一个轻量级的可注射消息/事件服务。您可以使用 RxJS主题实施该服务。

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. You can implement that service using RxJS Subjects.

这篇关于前端“微服务”与Angular 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆