Angular 2 background jobs

I am trying to figure out if it is possible to execute a background process when angular2 app starts.

Example:

  • for login there is a task that constantly checks the token expiration and if it expires redirect to login
  • there is a task running in the background to get the latest updates from the web api (i.e. incoming)

With old MVC models in schools, I used a much simpler cron job trying to view the layer, not sure what is possible with angular2.

+3


source to share


1 answer


For 1, you can use Web Worker . There is one little thing to remember about the web worker, is that inside one of them you cannot change the DOM, you need to pass messages to the main thread for it to do it



For 2, you can use Web Socket or Web Worker to stream data

0


source







All Articles