All Projects → alexeyraspopov → newsletter

alexeyraspopov / newsletter

Licence: MIT license
Observer done right

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to newsletter

uorb
C++ inter-thread publish/subscribe middleware ported from PX4 and redesigned based on POSIX
Stars: ✭ 35 (+169.23%)
Mutual labels:  publish-subscribe
angular-PubSub
Angular 1.x implementation of the Publish–Subscribe pattern.
Stars: ✭ 32 (+146.15%)
Mutual labels:  publish-subscribe
eda
eda is a library for implementing event-driven architectures.
Stars: ✭ 31 (+138.46%)
Mutual labels:  publish-subscribe
cloudenvoy
Cross-application messaging for Ruby and Rails using Google Cloud Pub/Sub
Stars: ✭ 31 (+138.46%)
Mutual labels:  publish-subscribe
walrus
🕑 Real-time event streaming platform built on top of gRPC streams
Stars: ✭ 15 (+15.38%)
Mutual labels:  publish-subscribe
Open62541
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Stars: ✭ 1,643 (+12538.46%)
Mutual labels:  publish-subscribe
Wisper
A micro library providing Ruby objects with Publish-Subscribe capabilities
Stars: ✭ 3,014 (+23084.62%)
Mutual labels:  publish-subscribe
Magic-Leap-Gesture-IoT-Example
Control lights in the physical world from the augmented world using hand gestures. Using Magic Leap Hand Poses (Gestures) and PubNub.
Stars: ✭ 18 (+38.46%)
Mutual labels:  publish-subscribe
zeroin
The only Event Emitter you need
Stars: ✭ 19 (+46.15%)
Mutual labels:  publish-subscribe
SEPA
Get notifications about changes in your SPARQL endpoint.
Stars: ✭ 21 (+61.54%)
Mutual labels:  publish-subscribe
emitter-queue
😴 Queue emitter events
Stars: ✭ 16 (+23.08%)
Mutual labels:  publish-subscribe
PubBus
A simple implementation of a MessageBus.
Stars: ✭ 19 (+46.15%)
Mutual labels:  publish-subscribe
talek
a Private Publish Subscribe System
Stars: ✭ 39 (+200%)
Mutual labels:  publish-subscribe
payload
A javascript single page application (SPA) driver for REST API payload management.
Stars: ✭ 16 (+23.08%)
Mutual labels:  publish-subscribe
hermes
ZMQ-based framework for building Pub-Sub Systems, written in Python 3.
Stars: ✭ 13 (+0%)
Mutual labels:  publish-subscribe

newsletter

npm install newsletter

Simple pub/sub implementation.

ESM Package

Starting from v4.0 this package fully moved to ES Modules and ES2015 code. This means no more build step before publishing to NPM.

Ideally you shouldn't spot any difference, but in case you face any issues, see this useful article.

You can also downgrade to v3.x to use all the same functionality, precompiled to ES5.

API

To create publisher instance use Newsletter constructor (see Usage). Instance implements next interface:

  • publish - invokes all listeners and pass some received data to them
  • subscribe - adds new listener (function) and returns subscription handling instance

Usage

// get newsletter
import { Newsletter } from 'newsletter';

// create instance
var signal = new Newsletter();

// subscribe notifications
var subscription = signal.subscribe((data) => console.log(data));

// publish some data to subscribers
signal.publish(13);

// remove listener
subscription.dispose();

There is a way to subscribe to a single update

var signal = new Newsletter();

// subscribe to a single update
var subscription = signal.subscribe((data) => {
  subscription.dispose();
  console.log(data);
});

// will call a listener and remove it
signal.publish(13);

// no listeners called
signal.publish(14);

The project is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].