This package has been deprecated

Author message:

🚚 @vangware/notify is now @lou.codes/notify

@vangware/notify
TypeScript icon, indicating that this package has built-in type declarations

1.0.19Β β€’Β PublicΒ β€’Β Published

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>

Package Sidebar

Install

npm i @vangware/notify

Weekly Downloads

20

Version

1.0.19

License

MIT

Unpacked Size

15.2 kB

Total Files

19

Last publish

Collaborators

  • loucyx