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

@daun/pubsub

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daun/pubsub

Simple event bus / pubsub broker

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Pub-Sub

Simple DOM-based event bus / pubsub broker.

Usage

import pubsub from '@daun/pubsub'

Publish events

The second argument will be passed to each event handler.

pubsub.publish('page:visit', { url: window.location })

Subscribe to events

pubsub.subscribe('page:visit', ({ detail }) => {
  console.log(detail.url)
})

Unsubscribe from events

The subscribe method returns a function that can be used to unsubscribe.

const unsubscribe = pubsub.subscribe('page:visit', () => { /* */ })
unsubscribe()

License

MIT License © Philipp Daun

Keywords

FAQs

Package last updated on 27 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

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