我一直在尝试为我们的应用程序使用 PWA,以确保它根据需要进行更新,但由于某种原因,checkForUpdate 和 versionUpdates 方法都没有解析为任何值。
constructor(
appRef: ApplicationRef,
updates: SwUpdate,
) {
if (updates.isEnabled) {
const appIsStable$ = appRef.isStable
.pipe(first(isStable => isStable === true));
const everyMinute$ = interval(60 * 1000);
const everyMinuteOnceAppIsStable$ = concat(appIsStable$, everyMinute$);
const checkForUpdatesSub = everyMinuteOnceAppIsStable$
.subscribe({
next: async updateFound => {
const update = await updates.checkForUpdate(); // My code reaches this point.
console.log(update); // However, my code never reaches this point.
}
});
}
}
也许订阅不支持
async
await
而是去.then(
等待promise解决并最终调用console.log
!
...
.subscribe({
next: updateFound => {
updates.checkForUpdate().then((update: any) => {
console.log(update); // However, my code never reaches this point.
});
}
});
...