Skip to main content
Module

x/async_channels/mod.ts>time.Ticker

Inspired by Go & Clojure Channels, async_channels provides channels as an asynchronous communication method between asynchronous functions.
Latest
class time.Ticker
import { time } from "https://deno.land/x/async_channels@v1.0.0-rc8/mod.ts";
const { Ticker } = time;

A Ticker holds a channel that delivers “ticks” of a clock at intervals.

Constructors

new
Ticker(duration: number, options?: ChannelOptions)

constructs a new Ticker containing a channel that will send the time on the channel after each tick. The period of the ticks is specified by the duration argument. The ticker will adjust the time interval or drop ticks to make up for slow receivers. The duration must be greater than zero; if not, NewTicker will throw. Stop the ticker to release associated resources.

Properties

readonly
c: Receiver<Date>

The channel on which the ticks are delivered.

Methods

reset(duration: number)

reset stops a ticker and resets its period to the specified duration. The next tick will arrive after the new period elapses.

stop turns off a ticker. After stop, no more ticks will be sent. stop does not close the channel, to prevent a concurrent goroutine reading from the channel from seeing an erroneous "tick".