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

watch-notify

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

watch-notify

The omnipresent publish subscribe design pattern.

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
21
decreased by-54.35%
Maintainers
1
Weekly downloads
 
Created
Source

Watch notify

The omnipresent publish subscribe design pattern. The observers are called in the same order that they are added. If an observer throws an error when executed, the exception is caught and the execution continue to the next one.

Installation

npm install watch-notify

How to use

Require and initialize watch-notify:

var watchNotify = require("watch-notify");

var watchNotify = new WatchNotify();

Watch on a specific topic:

var handle = watchNotify.watch("topic", function handler(message) {
  // this === scope
}, scope /* optional */);

The topic can also be a number:

var handle = watchNotify.watch(1337, function handler() { ... });

Notify on a specific topic:

watchNotify.notify("topic", "hi!");

Several types can be given to notify:

watchNotify.notify("topic", "message1", "message2", anObject, ...);

Remove an observer:

watchNotify.unwatch(handle);

Observe only once. The handler will be called once and then removed, so any new message on topic won't trigger it.

var handle = watchNotify.once("topic", function handler() { ... });

Remove the handler before it's even called for the first time:

watchNotify.unwatch(handle);

CHANGELOG

0.0.3 - 7 APR 2015

  • console.error when an observer throws an error to help with debugging

LICENSE

MIT

Keywords

FAQs

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

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