@agilearchitects/broadcast

Simple broadcast service. Subscribe/Unsubscribe and emit

Usage no npm install needed!

<script type="module">
  import agilearchitectsBroadcast from 'https://cdn.skypack.dev/@agilearchitects/broadcast';
</script>

README

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!");