Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/subscription/mod.ts>default

An event object that calls subscriptions each time the event is dispatched.
Latest
class default
import { default } from "https://deno.land/x/subscription@2.0.1/mod.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.