Professional JavaScript for Web Developers 第四版學習筆記 CHAPTER 27:WORKERS
Introduction to Workers 970
Comparing Workers and Threads 970
Types of Workers 971
Dedicated Web Worker 971
Shared Web Worker 971
Service Worker 971
The WorkerGlobalScope 971
WorkerGlobalScope Properties and Methods 972
Subclasses of WorkerGlobalScope 972
Dedicated Workers 973
Dedicated Worker Basics 973
Creating a Dedicated Worker 973
Worker Security Restrictions 974
Using the Worker Object 975
The DedicatedWorkerGlobalScope 976
Dedicated Workers and Implicit MessagePorts 976
Understanding the Dedicated Worker Lifecycle 977
Configuring Worker Options 979
Creating a Worker from Inline JavaScript 979
Dynamic Script Execution Inside a Worker 980
Delegating Tasks to Subworkers 982
Handling Worker Errors 983
Communicating with a Dedicated Worker 983
Communicating with postMessage() 983
Communicating with MessageChannel 984
Communicating with BroadcastChannel 986
Worker Data Transfer 987
Structured Clone Algorithm 987
Transferable Objects 988
SharedArrayBuffer 990
Worker Pools 993
Shared Workers 997
Shared Worker Basics 997
Creating a Shared Worker 997
SharedWorker Identity and Single Occupancy 998
Using the SharedWorker Object 999
The SharedWorkerGlobalScope 999
Understanding the Shared Worker Lifecycle 1000
Connecting to a Shared Worker 1001
Service Workers 1003
Service Worker Basics 1003
The ServiceWorkerContainer 1004
Creating a Service Worker 1004
Using the ServiceWorkerContainer Object 1005
Using the ServiceWorkerRegistration Object 1006
Using the ServiceWorker Object 1007
Service Worker Security Restrictions 1008
The ServiceWorkerGlobalScope 1008
Service Worker Scope Limitations 1010
The Service Worker Cache 1012
The CacheStorage Object 1013
The Cache Object 1014
Maximum Cache Storage 1017
Service Worker Clients 1017
Service Workers and Consistency 1018
Understanding the Service Worker Lifecycle 1019
The Parsed State 1020
The Installing State 1020
The Installed State 1021
The Activating State 1022
The Activated State 1023
The Redundant State 1024
Updating a Service Worker 1024
Inversion of Control and Service Worker Persistence 1024
Managing Service Worker File Caching with updateViaCache 1025
Forced Service Worker Operation 1025
Service Worker Messaging 1026
Intercepting a fetch Event 1028
Return from Network 1028
Return from Cache 1029
Return from Network with Cache Fallback 1029
Return from Cache with Network Fallback 1029
Generic Fallback 1029
Push Notifications 1030
Displaying Notifications 1030
Handling Notification Events 1031
Subscribing to Push Events 1031
Handling Push Events 1032
Summary 1033
-------------------------------------------------
Ultimately, most developers will find that service workers are most useful for two primary tasks: acting as a caching layer for network requests, and enabling push notifications. In this sense, the service worker is a tool designed to enable web pages to behave like native applications.