我正在使用Kendo UI中的RedialGauge和angular。
我rxjs每3分钟从一个api动态加载我的仪表数据,这是我的代码:
interval(2e5)
.pipe(
startWith(() => forkJoin(
this.service.getStatistics(),
this.service.otherCall()
)
),
switchMap(() => forkJoin(
this.service.getStatistics(),
this.service.otherCall()
)
),
retryWhen((err) => err.pipe(
take(3)
)
)
).subscribe(([statistics, others]) => {
this.statistics = statistics;
...
});
Run Code Online (Sandbox Code Playgroud)
这就是我想出的结果,虽然有点老套,但这是唯一真正有效的解决方案。
当我想更新仪表时,我基本上会重新加载组件。
public refreshComponent(): void {
const url = this.router.url;
this.router.navigateByUrl('/app', {skipLocationChange: true}).then(() => {
this.router.navigate([url]);
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
101 次 |
| 最近记录: |