1.0.19 • Published 2 years ago

@vangware/notify v1.0.19

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

Coverage License NPM Version Open Issues Size

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

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago