1.1.0 • Published 3 years ago

@agilearchitects/broadcast v1.1.0

Weekly downloads
2
License
MIT
Repository
-
Last release
3 years ago

Agile Architects / Broadcast

Simple broadcast service. Subscribe/Unsubscribe and emit

Example

import { BroadcastService } from "@agilearchitects/broadcast";

// Create service
const broadcastService = new BroadcastService();

// Create subscription
const subscription = broadcastService.subscribe<string>("bar", (payload?: string) => {
  // Do something awesome
});

// Emit "hello World!" to callback
broadcastService.emit("bar", "Hello World!");

// Unsubscribe
subscription.unsubscribe();

// Callback will not execute
broadcastService.emit("bar", "Hello World!");