Home > OS >  Why rxjs invoke immediately timer in 2304115513 milliseconds?
Why rxjs invoke immediately timer in 2304115513 milliseconds?

Time:08-13

I set a timer in rxjs to 2304115513 in milliseconds.

But when I run the timer the subscribe function is invoke immediately.

Why? I was expect to invoke after pass 2304115513 milliseconds.

stackblitz

import './style.css';
console.clear();
import { of, map, Observable, timer } from 'rxjs';

timer(2304115513).subscribe((r) => {
  console.log('tick!');
});

CodePudding user response:

timer calls setTimeout, and setTimeout uses a 32 bit signed integer in its implementation in most browsers. As a result, the maximum time you can do a timeout for is 2,147,483,647 milliseconds

See this page: https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value

  • Related