1.0.19 ā¢ Published 7 months ago
@vangware/notify v1.0.19
š£ Minimalistic Pub/Sub implementation.
Usage
š¦ Node
Install @vangware/notify
as a dependency:
pnpm add @vangware/notify
# or
npm install @vangware/notify
# or
yarn add @vangware/notify
Import it and use it:
import { broadcast } from "@vangware/notify";
const { emit, on } = broadcast<{ event: string }>();
const onEvent = on("event");
const offEvent = onEvent(console.log);
const emitEvent = emit("event");
emitEvent("Hello world 1"); // Logs "Hello world 1"
emitEvent("Hello world 2"); // Logs "Hello world 2"
offEvent();
emitEvent("Nope"); // Nothing happens
š¦ Deno
Import @vangware/notify
using the npm:
prefix, and use it directly:
import { broadcast } from "npm:@vangware/notify";
const { emit, on } = broadcast<{ event: string }>();
const onEvent = on("event");
const offEvent = onEvent(console.log);
const emitEvent = emit("event");
emitEvent("Hello world 1"); // Logs "Hello world 1"
emitEvent("Hello world 2"); // Logs "Hello world 2"
offEvent();
emitEvent("Nope"); // Nothing happens
š Browser
Import @vangware/notify
using esm.sh, and use it directly:
<script type="module">
import { broadcast } from "https://esm.sh/@vangware/notify";
const { emit, on } = broadcast<{ event: string }>();
const onEvent = on("event");
const offEvent = onEvent(console.log);
const emitEvent = emit("event");
emitEvent("Hello world 1"); // Logs "Hello world 1"
emitEvent("Hello world 2"); // Logs "Hello world 2"
offEvent();
emitEvent("Nope"); // Nothing happens
</script>
Useful links
- š Documentation: TypeDoc generated documentation.
- ā³ Changelog: List of changes between versions.
- ā Tests Coverage: Coveralls page with tests coverage.
1.0.19
7 months ago
1.0.18
7 months ago
1.0.17
7 months ago
1.0.16
7 months ago
1.0.15
7 months ago
1.0.14
7 months ago
1.0.13
7 months ago
1.0.12
7 months ago
1.0.10
8 months ago
1.0.9
8 months ago
1.0.8
8 months ago
1.0.7
8 months ago
1.0.6
8 months ago
1.0.5
8 months ago
1.0.4
8 months ago
1.0.3
8 months ago
1.0.2
8 months ago
1.0.1
8 months ago
1.0.0
8 months ago