{"id":15388218,"url":"https://github.com/georapbox/angular-pubsub","last_synced_at":"2026-04-01T20:44:56.682Z","repository":{"id":22430732,"uuid":"25768729","full_name":"georapbox/angular-PubSub","owner":"georapbox","description":"Angular 1.x implementation of the Publish–Subscribe pattern.","archived":false,"fork":false,"pushed_at":"2017-07-20T14:27:08.000Z","size":13,"stargazers_count":32,"open_issues_count":2,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T11:11:33.527Z","etag":null,"topics":["angularjs","callback","events","javascript","publish","publish-subscribe","pubsub","register","subscribe","topic"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/georapbox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-26T11:16:50.000Z","updated_at":"2022-12-13T18:37:49.000Z","dependencies_parsed_at":"2022-08-21T06:30:39.812Z","dependency_job_id":null,"html_url":"https://github.com/georapbox/angular-PubSub","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georapbox%2Fangular-PubSub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georapbox%2Fangular-PubSub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georapbox%2Fangular-PubSub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georapbox%2Fangular-PubSub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georapbox","download_url":"https://codeload.github.com/georapbox/angular-PubSub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249118846,"owners_count":21215630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angularjs","callback","events","javascript","publish","publish-subscribe","pubsub","register","subscribe","topic"],"created_at":"2024-10-01T14:55:59.974Z","updated_at":"2025-10-07T10:37:42.000Z","avatar_url":"https://github.com/georapbox.png","language":"JavaScript","readme":"# angular-PubSub\nAngular 1.x implementation of the [Publish–Subscribe](http://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) pattern.\n\n\u003e ### NOTE: This repository is no longer maintained.\n\u003e The current repository and the `npm` package are not going anywhere but for future projects, please consider using [PubSub](https://github.com/georapbox/PubSub) package instead. Check the `examples` folder for a working example in Angular 1.x application.\n\n[![npm version](https://badge.fury.io/js/angular-PubSub.svg)](http://badge.fury.io/js/angular-PubSub)\n[![Dependencies](https://david-dm.org/georapbox/angular-PubSub.svg?theme=shields.io)](https://david-dm.org/georapbox/angular-PubSub)\n[![devDependency Status](https://david-dm.org/georapbox/angular-PubSub/dev-status.svg)](https://david-dm.org/georapbox/angular-PubSub#info=devDependencies)\n\n## Installation\n\n### Git installation\n\n`$ git clone https://github.com/georapbox/angular-PubSub.git`\n\n### npm installation\n\n`$ npm install angular-PubSub --save`\n\n### Bower installation\n`$ bower install angular.pubsub`\n\n## Using PubSub\n\n### Register\nInclude `angular-pubsub.js` in your project after `angular.js` and register to your application:\n```js\nvar app = angular.module('app', ['PubSub']);\n```\n\n### Inject as dependancey\nInject the service as a dependancy of the application modules, to use it:\n```js\nvar MyController = app.controller('MyController', ['PubSub', function (PubSub) {\n  // do your stuff here...\n}]);\n```\n\n### Subscribing events\nThe \"listener\" is the function to be executed when an event is emitted.\n```js\nfunction listener(data, topic) {\n  console.log('An event is published.');\n  console.log(topic);\n  console.log(data);\n}\n\n// Subscribe to event\nvar sub = PubSub.subscribe('event-name', listener);\n\n// Subscribe to event and execute only one time\nvar subOnce = PubSub.subscribeOnce('event-name', listener)\n```\n\n### Publishing events\nThe `publish` method takes two arguments:\n\n- The first one is the name of the event.\n- 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.\n```js\nPubSub.publish('event-name', {prop1: value1, prop2: value2});\n```\n\n### Unsubscribing events\nThere are two ways to unsubscribe an event:\n\n- Unsubscribe from a specific topic based on a tokenized reference to the subscription.\n```js\nPubSub.unsubscribe(sub);\n```\n- Unsubscribe from a specific topic based on topic name. This way we can unsubscribe all events with the same name.\n```js\nPubSub.unsubscribe('event-name');\n```\n\n## Methods aliases\n- `on` - `subscribe`\n- `once` - `subscribeOnce`\n- `trigger` - `publish`\n- `off` - `unsubscribe`\n\n## Minify\n\n```sh\n$ npm run minify\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorapbox%2Fangular-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorapbox%2Fangular-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorapbox%2Fangular-pubsub/lists"}