JavaScript Edu Resources. Angular Courses. React Tutorials. Join us!

Web Workers

WebWorker support in Angular2 is designed to make it easy to leverage parallelization in your web application. When you choose to run your application in a WebWorker angular runs both your application’s logic and the majority of the core angular framework in a WebWorker.

  • This code is nearly the same as the TypeScript version with just a couple key differences:

    You can do almost everything in a WebWorker component that you can do in a typical Angular 2 Component.

  • MessageBus is a low level abstraction that provides a language agnostic API for communicating with angular components across any runtime boundary such as communication, communication, or communication.
  • Angular currently includes two stable MessageBus implementations, which are used by default when you run your application inside a WebWorker.
  • In TypeScript that would look like this:

    Once the channel has been initialized either side can use the and methods on the MessageBus to send and receive messages.

  • For example, if your MessageBus sends and receives JSON data you would do the following:

    Once you’ve implemented your custom MessageBus in either TypeScript or Dart you can tell angular to use it like so: In TypeScript:

    Notice how we call instead of from the UI side.



awesome-angular/WebWorkers.md at gh-pages · AngularClass/awesome-angular · GitHub

Comments are closed, but trackbacks and pingbacks are open.