I had created a service-worker and make it get to register. I used below code in some js file
self.addEventListener('install', function (event) {
console.log('installing');
})
self.addEventListener('activate', function (event) {
console.log('activating', event);
})
Can i store a variable value in angular. Like I want to store a value of 'x' in the cache by using a service worker. How can I do that?
Use IndexedDb for this.
You can store the value in IndexedDb inside of the Service Worker and then access it inside of the Angular app. The localForage library provides a nice to user wrapper around IndexedDb, you can use this library in both your Service Worker and inside of Angular.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With