1.0.28 ā€¢ Published 2 days ago

@lou.codes/notify v1.0.28

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

Coverage License NPM Version Open Issues Size

šŸ“£ 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

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