This is an example on how to update and Angular project (generated with angular-cli) in order to use Web Workers.
The example is a CPU intensive factorial calculator client that compute 50 factorial numbers starting by the number introduced in the form.
Do you wanna see it in action? Check the demo
In this repo you will 2 dev branches:
- master: the web workers version
- single-threaded: the single threaded version
Each branch require their own dependencies.
You can install them using: npm install
If you want to try by yourself:
- move to single-threaded branch
- Run
ng eject
to generate the webpack 2 file - Run a diff with master branch in order to understand the changes.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run npm start
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the -prod
flag for a production build.