Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

备稿计划: Web 后台 API Background_Synchronization_API, Background_Fetch_API #117

Open
iugo opened this issue Jun 11, 2022 · 0 comments

Comments

@iugo
Copy link
Member

iugo commented Jun 11, 2022

在 iOS 开发 中, 有一些方法让 App 在后台进行一些数据更新:

https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app

在 Web 上, 一般是离开这个页面就不能有任何交互了. 但是 Chrome 提供了一种方案来处理这种情况, 分为两套 API:

https://developer.mozilla.org/en-US/docs/Web/API/Background_Synchronization_API

https://developer.mozilla.org/en-US/docs/Web/API/Background_Fetch_API

Background Synchronization API 的目的是为了处理网络不佳的情况, 但因为依赖 service worker, 所以随时有被关闭的情况.

而 Background_Fetch_API 基本上只是为了大文件的下载.

这里要说一下 Web 开发与 App 开发重要的一点不同, Web 会将异步工作交给 服务器, 而 App 是可以自己控制异步工作的. 或者说, Web 能做的更少, 功能上非常收敛.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant