与模块联合会的角度微主恩截止HTTP请求在主机应用程序中
我需要拦截来自主机应用程序中所有遥控器的所有http请求,以便重新启动监视用户不活动的计时器。所有应用程序都使用Angular与WebPack模块联合使用。 有什么想法吗?
最好的应该是主机应用拦截器可以拦截所有请求,我发现的替代解决方案是:
- 通过对象 window 共享一个全局变量,每当从遥控器中提出请求时,将其从遥控器重置并在主机中增加每秒
- 使用自定义事件的应用程序与已提出请求的主机应用程序进行通信,并且主机必须重置一个
可首选解决方案的计数?
I need to intercept all HTTP request coming from all the remotes in my host application in order to restart a timer that monitor the user inactivity. All applications are using Angular with Webpack Module Federation.
Any ideas?
The best should be the host app interceptor could intercept all requests, alternatives solutions i found are:
- sharing a global variable through the object window resetting it from the remote whenever a request is made from it and increment in host app every second
- using custom events to communicate to the host app that a request has been made and the host has to reset the count
Which is the preferrable solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我本周遇到了这种情况,对我而言,最合适的是创建一个使拦截器暴露的角图书馆,并通过模块联合会在外壳和微额线之间共享此库。
I ran into this situation this week, and for me the best fit was creating an angular library that exposes the interceptor, and share this library between the shell and the microfrontends through module federation.