Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

timeInterval

Emits an object containing the current value, and the time that has passed between emitting the current value and the previous value, which is calculated by using the provided scheduler's now() method to retrieve the current time at each emission, then calculating the difference. The scheduler defaults to asyncScheduler, so by default, the interval will be in milliseconds.

Convert an Observable that emits items into one that emits indications of the amount of time elapsed between those emissions.

Example

Emit interval between current value with the last value

import { interval, timeInterval } from 'rxjs';

const seconds = interval(1000);

seconds
  .pipe(timeInterval())
  .subscribe(value => console.log(value));

// NOTE: The values will never be this precise,
// intervals created with `interval` or `setInterval`
// are non-deterministic.

// { value: 0, interval: 1000 }
// { value: 1, interval: 1000 }
// { value: 2, interval: 1000 }
function timeInterval<T>(scheduler?: SchedulerLike): OperatorFunction<T, TimeInterval<T>>;
§
timeInterval<T>(scheduler?: SchedulerLike): OperatorFunction<T, TimeInterval<T>>
[src]

§Type Parameters

§Parameters

§
scheduler?: SchedulerLike optional
[src]

§Return Type

§

A function that returns an Observable that emits information about value and interval.