# purin-pubsub

> Only 1KB, TypeScript-friendly Publish/Subscribe library.

Latest version **1.0.4** (published 2023-05-12) · 0 weekly downloads

## Install

```sh
npm install purin-pubsub
pnpm add purin-pubsub
yarn add purin-pubsub
bun add purin-pubsub
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-05-12 |
| First published | 2023-05-10 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | akirarika |
| Keywords | typescript, pub/sub, publish, subscribe |

## Links

- npm: https://www.npmjs.com/package/purin-pubsub
- npm.io page: https://npm.io/package/purin-pubsub

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2023-05-12
- 1.0.3 — 2023-05-10

## README

# purin-pubsub

Only 1KB, TypeScript-friendly Publish/Subscribe library.

> Tips: Purin just Pudding

## Where to get

```sh
npm i purin-pubsub
```

## How to use

```ts
import { definePurinPubsub } from "purin-pubsub";

type YourData = {
  count: number;
};

const purin = definePurinPubsub<YourData>();

const unsubcribe = purin.subscribe("count", ({ key, value }) => {
  console.log(key, value); // echo: count 1

  // unsubscribe is also very simple! execute it, this function will not be executed
  unsubcribe();
});

purin.publish("count", 1);

// or you can arbitrarily retrieve the value of the last published value
console.log(purin.pull("count")); // echo: 1
```

---
_Source: https://npm.io/package/purin-pubsub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
