Skip to main content
Module

x/async_channels/mod.ts>time.tick

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

tick is a convenience wrapper for new Ticker(d) providing access to the ticking channel only. While tick is useful for clients that have no need to shut down the Ticker, be aware that without a way to shut it down the underlying Ticker cannot be recovered by the garbage collector; it "leaks".

Examples

Example 1

import { time } from "./mod.ts";

for await (const cur of time.tick(5 * time.Duration.Second)) {
  console.log(`current time: ${cur}`)
}

type

(duration: number) => Receiver<Date>