In this tutorial, we will learn about the interval and timer operator of RXJS.

Interval Operator

Interval Operator make calls on some interval

Example:

import { interval } from "rxjs";    
------------------------------
const source$= interval(2000);
 
    source$.subscribe((res) => {
      console.log(res);
    });

Output: 
1,2,3,4,5...........

The above example will print the response every two seconds as defined in the interval operator.

Timer Operator

Timer works same as but takes two argument delay, interval.

Syntax:

timer(delay,interval)

Example:

import { timer} from "rxjs";    

------------------------------

const source$ = timer(5000, 1000);

    source$.subscribe((res) => {

      console.log(res);

    });

Output: 

1,2,3,4,5...........

In Above eample timer will start after five seconds and will run for every seconds untill we stop.

Topics covered:

Found this article helpful?

TutsCoder tutorials are free and ad-light — supported by readers like you. Buy me a coffee (or two ☕☕) as a token of appreciation and help keep Angular & Node.js content coming!

One-time. No subscription. 100% optional. 🙏 Every coffee counts!

Leave a Comment

Have a question or feedback? Drop it below — I read every comment!

Spam-free zone — comments are reviewed before publishing.

No comments yet — be the first to start the conversation!

Available for Projects

Need Help With Your
Angular or Node.js Project?

7+ years of MEAN Stack experience. I build scalable Angular 21 apps, Node.js APIs, and SaaS products — delivered on time, every time.

7+ Years MEAN Stack Angular 21 + Nx Expert 20+ Projects Delivered Remote / Freelance