Closed
Description
Bug Report
Current Behavior
When using the delay operator multiple times, and each time passing a date object into it, subsequent delay operators seem to accumulate the date differential from previous delay operators. See reproduction url for a code example.
Reproduction
- REPL or Repo link:
https://stackblitz.com/edit/typescript-rx-playground-4fssrc?file=index.ts
import { map, delay, tap, take } from 'rxjs/operators';
import { Observable, of, interval } from 'rxjs';
// console log every 1 second
interval(1000).pipe(
take(17)
).subscribe(num => {
if (num === 10) console.log(num + `: Expecting to see 'innitTimePlus10s' here...`);
else console.log(num);
});
// save time on file init and then create date for 5 seconds and 10 seconds from init
const initTime = new Date();
const initTimePlus5s = new Date(initTime.getTime() + 5000);
const initTimePlus10s = new Date(initTime.getTime() + 10000);
// console log after 5 seconds after init, and again after 10 seconds _after init_
of(null).pipe(
delay(initTimePlus5s),
tap(() => console.log('initTimePlus5s')),
delay(initTimePlus10s),
tap(() => console.log('initTimePlus10s')),
).subscribe();
Expected behavior
/**
* Expected result:
*
* 0
* 1
* 2
* 3
* 4
* 5
* initTimePlus5s
* 6
* 7
* 8
* 9
* 10
* initTimePlus10s
*/
Environment
- Runtime: Chrome 79.0.3945.117
- RxJS version: 6.5.2
Activity