From 51a89c32c4b10b69a409a5665198aa870b3adcd8 Mon Sep 17 00:00:00 2001 From: Judy Bogart Date: Wed, 11 Mar 2020 10:14:10 -0700 Subject: [PATCH] docs: update and edit web-worker page (#36026) PR Close #36026 --- aio/content/guide/web-worker.md | 39 ++++++++++++++++++++++----------- aio/content/navigation.json | 4 ++-- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/aio/content/guide/web-worker.md b/aio/content/guide/web-worker.md index 2bec5b635c..c05bae8093 100644 --- a/aio/content/guide/web-worker.md +++ b/aio/content/guide/web-worker.md @@ -1,17 +1,31 @@ -# Using web workers with Angular CLI +# Background processing using web workers -[Web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) allow you to run CPU intensive computations in a background thread, freeing the main thread to update the user interface. +[Web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) allow you to run CPU-intensive computations in a background thread, +freeing the main thread to update the user interface. +If you find your application performs a lot of computations, such as generating CAD drawings or doing heavy geometrical calculations, using web workers can help increase your application's performance. -If you find your application becomes unresponsive while processing data, using web workers can help. +
addEventListener('message', ({ data }) => { @@ -20,7 +34,7 @@ Running this command will: }); -- add scaffolded code to `src/app/app.component.ts` to use the worker: +- Adds the following scaffold code to `src/app/app.component.ts` to use the worker. if (typeof Worker !== 'undefined') { @@ -36,11 +50,10 @@ Running this command will: } -After the initial scaffolding, you will need to refactor your code to use the web worker by sending messages to and from. +After you generate this initial scaffold, you must refactor your code to use the web worker by sending messages to and from the worker. -## Caveats +