Rxjs timeout()对于某些将来的日期抛出错误

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

Rxjs timeout()在某些DaysTimestamp]中无法正常工作

import { interval } from 'rxjs';
import { timeout } from 'rxjs/operators';

const seconds = interval(1000);

seconds.pipe(
  // Present Date (Thu Mar 19 2020 14:40:58) => 1584628858530
  // to UTC time & date: (Wed Dec 30 2020 18:30:00) => 1609353000000-------Not working
  // to UTC time & date: (Mon Dec 30 2030 18:30:00) => 1924885800000-------Working
  timeout(new Date(1609353000000)), // replace timestamp
)
.subscribe(
    value => console.log(value), 
    err => console.log(err)
);

单击here以获取原始文档。检查示例2。

Rxjs timeout()在某些天或从'rxjs'导入时间戳{间隔}时无法正常工作;从'rxjs / operators'导入{超时}; const seconds = interval(1000); seconds.pipe(// ...

angular typescript rxjs
1个回答
0
投票

我发现了更大的超时时间的另一种方法

    const largeTimeout = new Date(1924885800000); // put your own future date
    const expireTime = timer().pipe(delay(largeTimeout));
    expireTime.subscribe(() => {
      console.log("time expired !")
    });
© www.soinside.com 2019 - 2024. All rights reserved.