New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

purin-pubsub

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

purin-pubsub

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

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

purin-pubsub

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

Tips: Purin just Pudding

Where to get

npm i purin-pubsub

How to use

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

Keywords

typescript

FAQs

Package last updated on 12 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts