Socket
Socket
Sign inDemoInstall

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 - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"name": "watch-notify",
"description": "The omnipresent publish subscribe design pattern.",
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://github.com/flams/watch-notify",

@@ -6,0 +6,0 @@ "licenses": [

Watch notify
=============
The omnipresent publish subscribe design pattern.
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.

@@ -16,9 +16,56 @@ Installation

Require watch-notify:
Require and initialize watch-notify:
```js
var watchNotify = require("watch-notify");
var watchNotify = new WatchNotify();
```
Watch on a specific topic:
```js
var handle = watchNotify.watch("topic", function handler(message) {
// this === scope
}, scope /* optional */);
```
The topic can also be a number:
```js
var handle = watchNotify.watch(1337, function handler() { ... });
```
Notify on a specific topic:
```js
watchNotify.notify("topic", "hi!");
```
Several types can be given to notify:
```js
watchNotify.notify("topic", "message1", "message2", anObject, ...);
```
Remove an observer:
```js
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.
```js
var handle = watchNotify.once("topic", function handler() { ... });
```
Remove the handler before it's even called for the first time:
```js
watchNotify.unwatch(handle);
```
LICENSE

@@ -25,0 +72,0 @@ =======

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