Worker Service Implementation

10 views
Skip to first unread message

Stephane Belzile

unread,
Jan 10, 2019, 1:17:46 AM1/10/19
to Angular and AngularJS discussion
Hi,

I'm currently working on improving an angular app which runs as an ios app (using cordova). I've been asked to improve its performance. The app is used by health professionnals on sites where Internet might not be available or be very slow which leads to poor startup performances and loss of connectivity. It has performance issues on startup because the app downloads a full directory of images.

I'm pretty new to angular and as I was searching for advices to fix those problems and I found this Service Worker feature that seemed to bes a great fit for fixing my problems allowing my app t download all its images asynchronously and preventing my app from failing when connectivity was lost. Since all my app is doing is sending info to the server, keeping outgoing calls into a local cache was making sense.

I tried to build my service following tutorials (https://www.youtube.com/watch?v=5YtNQJQu31Y&t=20s for example) but I'm not sure I have all prerequisites intlalled.

First of all, opening angular.min.js, I see tat I'm using AngularJs 1.4.2. Then, my tutorial asks me to run th following command on Microsoft Code (Mac) : ng add @angular/pwa. This command is supposed to update my project to include a basic service implementation. But all I get is a "ng comand not found" message.

I'm asking if my current setup (Angular 1.4.2) is compatible with service worker. And I'm also wondering if there's something missing preventing me from running ng commands in Microsoft Code.

Or maybe someone has a better idea to solve my problems

Thank you


Sander Elias

unread,
Jan 10, 2019, 7:28:44 AM1/10/19
to Angular and AngularJS discussion
Hi Stephane,

Service-worker works fine with any angular version. However, I'm talking here about the browser's supported version. The Angular service-worker is made for Angular, not AngularJs. As is the Angular-cli.
For an AngularJs application, you are on your own for adding the service-worker. Check out Google's WorkBox project. That will probably address all you need.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages