RxJS interval() Creation OperatorRxJS interval() operator is a creation operator used to create an observable that emits a sequence of integers every time for the given time interval on a specified SchedulerLike. It emits incremented numbers periodically in time. In other words, we can say that the RxJS interval() operator returns an observable that emits sequential numbers every specified interval of time. It emits an infinite sequence of ascending integers, with a constant interval of time of your choosing between emissions. Syntax:Following is the syntax of the RxJS interval() creation operator: Or Or Parameter Explanation
Return valueThe RxJS interval() operator returns an observable that emits a sequentially increasing number within the given interval of time. Let us see some examples of the RxJS interval() operator to understand it clearly. Example 1 (Emits ascending numbers infinite times)Output: After executing the above example, you will see the following result: In the above example, you can see that it is emitting values infinite times until you stop the process by pressing the Ctrl + C button. Example 2 (Emits ascending numbers up to a specific number)Output: After executing the above example, you will see the following result: In the above example, you can see that it is emitting values only up to 8 numbers which we have specified earlier.
Next TopicRxJS Operators
|