Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why rxjs invoke immediately timer in 2304115513 milliseconds?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

stackblitz

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

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

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading