All Projects → georapbox → angular-PubSub

georapbox / angular-PubSub

Licence: MIT license
Angular 1.x implementation of the Publish–Subscribe pattern.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to angular-PubSub

dead-simple
💀💡 Dead simple PubSub and EventEmitter in JavaScript
Stars: ✭ 21 (-34.37%)
Mutual labels:  events, pubsub, publish, subscribe
pg-pubsub
Reliable PostgreSQL LISTEN/NOTIFY with inter-process lock support
Stars: ✭ 50 (+56.25%)
Mutual labels:  events, pubsub, publish, subscribe
Wisper
A micro library providing Ruby objects with Publish-Subscribe capabilities
Stars: ✭ 3,014 (+9318.75%)
Mutual labels:  events, pubsub, publish-subscribe
fastapi websocket pubsub
A fast and durable Pub/Sub channel over Websockets. FastAPI + WebSockets + PubSub == ⚡ 💪 ❤️
Stars: ✭ 255 (+696.88%)
Mutual labels:  pubsub, publish, subscribe
watermill-amqp
AMQP Pub/Sub for the Watermill project.
Stars: ✭ 27 (-15.62%)
Mutual labels:  events, pubsub
dry-events
Pub/sub system
Stars: ✭ 102 (+218.75%)
Mutual labels:  events, pubsub
watermill-http
HTTP Pub/Sub for the Watermill project.
Stars: ✭ 16 (-50%)
Mutual labels:  events, pubsub
Pg Listen
📡 PostgreSQL LISTEN & NOTIFY for node.js that finally works.
Stars: ✭ 348 (+987.5%)
Mutual labels:  events, pubsub
Sysend.js
Send messages between open pages or tabs in same browser
Stars: ✭ 347 (+984.38%)
Mutual labels:  events, callback
Twitchlib
C# Twitch Chat, Whisper, API and PubSub Library. Allows for chatting, whispering, stream event subscription and channel/account modification. Supports .NET Core 2.0
Stars: ✭ 519 (+1521.88%)
Mutual labels:  events, pubsub
Go Sdk
Dapr SDK for go
Stars: ✭ 149 (+365.63%)
Mutual labels:  events, pubsub
azure-service-bus-go
Golang library for Azure Service Bus -- https://aka.ms/azsb
Stars: ✭ 67 (+109.38%)
Mutual labels:  events, topic
Rocketman
🚀 Rocketman help build event-based/pub-sub code in Ruby
Stars: ✭ 139 (+334.38%)
Mutual labels:  events, pubsub
micro-typed-events
The smallest, most convenient typesafe TS event emitter you'll ever need
Stars: ✭ 39 (+21.88%)
Mutual labels:  events, pubsub
SEPA
Get notifications about changes in your SPARQL endpoint.
Stars: ✭ 21 (-34.37%)
Mutual labels:  events, publish-subscribe
x86-Assembly-Reverse-Engineering
🛠 Knowledge about the topic of x86 assembly & disassembly 🛠
Stars: ✭ 27 (-15.62%)
Mutual labels:  register, topic
cloudenvoy
Cross-application messaging for Ruby and Rails using Google Cloud Pub/Sub
Stars: ✭ 31 (-3.12%)
Mutual labels:  pubsub, publish-subscribe
webfunc
Universal Serverless Web Framework. Write Express apps ready to be deployed to Zeit-Now, Google Cloud Functions (incl. functions reacting to Pub/Sub topics or Storage changes), and AWS Lambdas.
Stars: ✭ 71 (+121.88%)
Mutual labels:  topic, pubsub
Wsify
Just a tiny, simple and real-time self-hosted pub/sub messaging service
Stars: ✭ 452 (+1312.5%)
Mutual labels:  topic, pubsub
Samples
Community driven repository for Dapr samples
Stars: ✭ 104 (+225%)
Mutual labels:  events, pubsub

angular-PubSub

Angular 1.x implementation of the Publish–Subscribe pattern.

NOTE: This repository is no longer maintained.

The current repository and the npm package are not going anywhere but for future projects, please consider using PubSub package instead. Check the examples folder for a working example in Angular 1.x application.

npm version Dependencies devDependency Status

Installation

Git installation

$ git clone https://github.com/georapbox/angular-PubSub.git

npm installation

$ npm install angular-PubSub --save

Bower installation

$ bower install angular.pubsub

Using PubSub

Register

Include angular-pubsub.js in your project after angular.js and register to your application:

var app = angular.module('app', ['PubSub']);

Inject as dependancey

Inject the service as a dependancy of the application modules, to use it:

var MyController = app.controller('MyController', ['PubSub', function (PubSub) {
  // do your stuff here...
}]);

Subscribing events

The "listener" is the function to be executed when an event is emitted.

function listener(data, topic) {
  console.log('An event is published.');
  console.log(topic);
  console.log(data);
}

// Subscribe to event
var sub = PubSub.subscribe('event-name', listener);

// Subscribe to event and execute only one time
var subOnce = PubSub.subscribeOnce('event-name', listener)

Publishing events

The publish method takes two arguments:

  • The first one is the name of the event.
  • The second one (optional) is the data we may want to pass along as. We can pass data along using an array or an object as shown below.
PubSub.publish('event-name', {prop1: value1, prop2: value2});

Unsubscribing events

There are two ways to unsubscribe an event:

  • Unsubscribe from a specific topic based on a tokenized reference to the subscription.
PubSub.unsubscribe(sub);
  • Unsubscribe from a specific topic based on topic name. This way we can unsubscribe all events with the same name.
PubSub.unsubscribe('event-name');

Methods aliases

  • on - subscribe
  • once - subscribeOnce
  • trigger - publish
  • off - unsubscribe

Minify

$ npm run minify
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].