PWA 软件有效 checkForUpdate 从未解决

问题描述 投票:0回答:1

我一直在尝试为我们的应用程序使用 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.
          }
        });
    }
  }
angular progressive-web-apps service-worker angular-service-worker
1个回答
0
投票

也许订阅不支持

async
await
而是去
.then(
等待promise解决并最终调用
console.log

...
.subscribe({
      next: updateFound => {
        updates.checkForUpdate().then((update: any) => {
            console.log(update); // However, my code never reaches this point.
        });
      }
    });
    ...
© www.soinside.com 2019 - 2024. All rights reserved.