Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

publisher-subscriber-pattern

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

publisher-subscriber-pattern

Publisher subscriber pattern that can be used with different event emitters including browser window

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-72.73%
Maintainers
1
Weekly downloads
 
Created
Source

About

  • Javascript implementation of publisher subscriber pattern
  • Can be used with different event emitters including browser window
  • Provides Publisher class

API

Publisher

  • Takes arguments: emitterInstance, addEventListener and removeEventListener
  • Exposes methods: subscribe, unsubscribeAll and eventSubscribersCount
  • Has property: subscribersCount

Arguments

emitterInstance
  • Object that will be bound to addEventListener and removeEventListener as this (see Function.prototype.bind)
addEventListener and removeEventListener
  • Methods exposed by emitterInstance which add and remove event listeners, respectively

Methods

subscribe
  • Requires two arguments: eventName and eventCallback
  • Accepts optional argument: subscriberInstance that will be bound to eventCallback as this
  • Subscribes eventCallback to eventName, so whenever event occurs the eventCallback is called (with subscriberInstance as this, if provided)
unsubscribeAll
  • Unsubscribes all eventCallbacks from all eventNames
  • Runs removeEventListener of emitterInstance fro all eventNames
eventSubscriberCount
  • Requires argument: eventName
  • Returns number of eventCallbacks subscribed to the evenName

Properties

subscribersCount
  • Returns number of eventCallbacks subscribed to all evenNames

Stack

  • Typescript
  • Jasmine, chai, sinon
  • Babel
  • Node (EventEmitter)

Keywords

FAQs

Package last updated on 07 Sep 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc