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

subscribers

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subscribers

Minimal subscription/notification implementation. Think of it as a “single event”.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

subscribers

A tiny library to manage lists of subscribers. Think of it as a “single event”. Use it when an event emitter is too much.

Focus has been minimal API surface and fast notification.

Installation

npm install subscribers

API

  • Import the library:
var subscribers = require('subscribers');
  • create a list of subscribers
var list = subscribers();
// or in ES6:
const {subscribe, notify} = subscribers();
  • register subscribers:
list.subscribe(function() { /* ... */ });
subscribe(() => {}); // ES6
  • notify subscribers:
list.notify({some: 'value'} /*, ... */);
notify({any: 'other value'} /*, ... */); // does not depend on `this` binding
  • unsubscribe:
var unsubscribe = subscribe(function() {});
unsubscribe();
  • Use it in other objects:
class UnicornNews {
  constructor() {
    const {notify, subscribe} = subscribers();
    this.subscribe = subscribe; // does not depend on `this` binding
  }
}

Keywords

subscribe

FAQs

Package last updated on 22 Jun 2015

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