In my angular project I have this kind of code:
this.swUpdate.available.subscribe(() => {
...
});
It work fine but gives me the warning about activated
being deprecated.
What should I do to fix this warning?
I believe activated
and activateUpdate()
are different things. You call activateUpdate()
, then when it's done, activated
happens.
Furthermore, activated
and available
are definitely different things (your question references both). available
means an update is detected; activated
means it's been installed.
According to the docs (https://angular.io/api/service-worker/SwUpdate), the replacement for available
is:
import {filter, map} from 'rxjs/operators';
// ...
const updatesAvailable = swUpdate.versionUpdates.pipe(
filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'),
map(evt => ({
type: 'UPDATE_AVAILABLE',
current: evt.currentVersion,
available: evt.latestVersion,
})));