1.0.28 ā¢ Published 2 days ago
@lou.codes/notify v1.0.28
š£ Minimalistic Pub/Sub implementation.
Usage
š¦ Node
Install @lou.codes/notify
as a dependency:
pnpm add @lou.codes/notify
# or
npm install @lou.codes/notify
# or
yarn add @lou.codes/notify
Import it and use it:
import { broadcast } from "@lou.codes/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 @lou.codes/notify
using the npm:
prefix, and use it directly:
import { broadcast } from "npm:@lou.codes/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 @lou.codes/notify
using esm.sh, and use it directly:
<script type="module">
import { broadcast } from "https://esm.sh/@lou.codes/notify";
const { emit, on } = broadcast();
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.28
2 days ago
1.0.26
16 days ago
1.0.27
15 days ago
1.0.25
17 days ago
1.0.24
22 days ago
1.0.22
23 days ago
1.0.21
28 days ago
1.0.19
1 month ago
1.0.18
1 month ago
1.0.20
1 month ago
1.0.17
1 month ago
1.0.16
1 month ago
1.0.15
1 month ago
1.0.14
2 months ago
1.0.13
3 months ago
1.0.12
4 months ago
1.0.11
4 months ago
1.0.10
4 months ago
1.0.9
4 months ago
1.0.8
4 months ago
1.0.7
5 months ago
1.0.6
5 months ago
1.0.5
5 months ago
1.0.4
5 months ago
1.0.3
5 months ago
1.0.2
5 months ago
1.0.1
6 months ago
1.0.0
6 months ago