Skip to main content
Module

x/forever/deps.ts>Event

A deno function to run a callback forever, until manually cancelled.
Latest
class Event
import { Event } from "https://deno.land/x/forever@1.1.0/deps.ts";

A subscribable event.

Type Parameters

optional
T extends unknown[] = []

Properties

private
readonly
_subscriptions: Map<Subscription<T>, boolean>

The listeners that are currently subscribed to the event.

Methods

async(): AsyncIterableIterator<T> & { close(): Promise<void>; }

Get an async iterator.

dispatch(...args: T)

Fire the event and call all subscriptions.

pull(): Promise<T>

Pull the next dispatch from the event return the dispatched data.

subscribe(...listeners: Subscription<T>[]): this

Subscribe to the event.

subscribeOnce(...listeners: Subscription<T>[]): this

Subscribe to the event once.

unsubscribe(...listeners: Subscription<T>[]): this

Unsubscribe to the event.