0.0.1 • Published 10 months ago

ab-subscription v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

Subscription

A simple subscription management utility for handling event subscriptions and dispatching in TypeScript.

Features

  • Subscribe to events with callback functions.
  • Dispatch events to all active subscribers.
  • Unsubscribe at any time.

Installation

You can install the package via npm:

npm i ab-subscription

Usage

Import the subscription function and create a subscription instance:

import subscription from "ab-subscription";

const { subscribe, dispatch } = subscription();

// Subscribe to an event
const unsubscribe = subscribe((event) => {
  console.log("Received event:", event);
});

// Dispatch an event to all subscribers
dispatch("Hello, Subscribers!");

// Unsubscribe from the event
unsubscribe();
0.0.1

10 months ago