不支持它的浏览器上的Angular Service Worker [英] Angular Service Worker on the browsers that do not support it

查看:134
本文介绍了不支持它的浏览器上的Angular Service Worker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular团队做得很好,并在版本5中引入了服务人员支持。文档很有帮助,在阅读相关文章后,我真的可以看到事情如何进行,但是这里没有涉及一个主题。

Angular team made a great job and introduced service workers support in the version 5. The documentation is quite helpful and I can really see how the things will work right after reading the related articles, however there is one topic that is not covered there. How does this all work in the browsers that do not support service workers.

这是在说什么:


您的应用程序必须在支持服务
worker的Web浏览器中运行。当前,
支持最新版本的Chrome和Firefox。要了解其他准备好服务工作人员
的浏览器,请参阅我可以使用页面。

Your application must run in a web browser that supports service workers. Currently, the latest versions of Chrome and Firefox are supported. To learn about other browsers that are service worker ready, see the Can I Use page.

我可以使用显示<在相对重要的浏览器中,href = https://caniuse.com/#feat=serviceworkers rel = nofollow noreferrer>对该功能的支持不佳。我可以在无法正常工作的IE11中生存下来,但是Safari(尤其是移动版)是我不希望自己不受支持的事情。

Can I Use shows quite a poor support of the feature in relatively important browsers. I can survive the not working IE11, but Safari (especially mobile) is a thing I wouldn't like to keep unsupported.

所以,我的目的是要知道角服务工作者模块,服务,这些服务提供的事件等将在不支持服务工作者的浏览器上运行。

So, my intention would be to know how the angular service worker module, services, events those services provide etc will behave on the browser that does not support service workers.

所有这些只是默默失败?是否会触发事件?是否会请求 ngsw-worker.js

Will all those just silently fail? Will the events be triggered anyhow? Will the ngsw-worker.js be requested? Will something be cached in IndexedDB instead of service worker?

该解决方案看起来很酷,但是我不能回答问题我应该使用它吗?,直到解决方案看起来不错了。我知道上述问题的答案。

The solution looks cool, however I cannot answer the question should I use it? until I know the answers on the questions above.

推荐答案

官方回复

Angular SW仅在支持服务工作者的浏览器中工作。这包括所有应用程序集成(例如SwUpdate服务)。

The Angular SW only works in browsers which support service workers. This includes all of the application integration (e.g. the SwUpdate service).

如果当前浏览器不支持软件。

If SWs are unsupported in the current browser.


  • SW脚本和ngsw.json将永远不会下载。

  • 主动尝试与SW进行交互,例如调用-

  • SwUpdate.checkForUpdate()将返回被拒绝的诺言。

  • 被动地监听SW观察对象(例如SwUpdate.available)将永远不会触发-观察对象将永远不会发出。

  • The SW script and ngsw.json will never be downloaded.
  • Active attempts to interact with the SW, such as calling -
  • SwUpdate.checkForUpdate() will return rejected promises.
  • Passive attempts to listen to SW Observables such as SwUpdate.available will simply never trigger - the Observables will never emit.

这篇关于不支持它的浏览器上的Angular Service Worker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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