I am building an Angular 14 app. In this app I want to check for updates to the app bundle automatically.
I use the below code and it works good but the checks are done like every 20 minutes (not sure) but I need it to check every minute.
public checkForUpdates(): void {
this.updates.versionUpdates.pipe(filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'),
map(evt => ({
type: 'UPDATE_AVAILABLE',
current: evt.currentVersion,
available: evt.latestVersion,
}))).subscribe(evt => {
console.log('Found update, prompting user');
this.promptUser();
});
}
Before updating from version 11 of Angular to 14 I used this code and it worked fine and it checked every minute.
public checkForUpdates(): void {
this.updateSubscription = this.updates.available.subscribe(event => this.promptUser());
if (this.updates.isEnabled) {
this.updates.activateUpdate();
interval(60000).subscribe(() => {
this.updates.checkForUpdate().then(() => {
console.log('Checking for updates');
});
});
}
}