{"id":15207111,"url":"https://github.com/knalli/angular-vertxbus","last_synced_at":"2025-10-02T23:35:42.616Z","repository":{"id":12526920,"uuid":"15196820","full_name":"knalli/angular-vertxbus","owner":"knalli","description":"AngularJS 1.x service wrapper for the Vert.x Event Bus","archived":true,"fork":false,"pushed_at":"2019-06-13T21:56:45.000Z","size":5409,"stargazers_count":79,"open_issues_count":0,"forks_count":24,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-14T18:48:53.999Z","etag":null,"topics":["angularjs","babeljs","cdnjs","javascript","messaging","vertx","vertxbus"],"latest_commit_sha":null,"homepage":"https://knalli.github.io/angular-vertxbus.docs/docs/","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/knalli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-15T02:55:12.000Z","updated_at":"2023-07-25T13:50:12.000Z","dependencies_parsed_at":"2022-07-08T00:56:04.504Z","dependency_job_id":null,"html_url":"https://github.com/knalli/angular-vertxbus","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knalli%2Fangular-vertxbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knalli%2Fangular-vertxbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knalli%2Fangular-vertxbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knalli%2Fangular-vertxbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knalli","download_url":"https://codeload.github.com/knalli/angular-vertxbus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235051584,"owners_count":18928185,"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","babeljs","cdnjs","javascript","messaging","vertx","vertxbus"],"created_at":"2024-09-28T06:22:03.323Z","updated_at":"2025-10-02T23:35:42.161Z","avatar_url":"https://github.com/knalli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# angular-vertxbus\n\n![Bower version](https://img.shields.io/bower/v/angular-vertxbus.svg) [![npm version](https://img.shields.io/npm/v/angular-vertxbus.svg)](https://www.npmjs.com/package/angular-vertxbus) [![cdnjs](https://img.shields.io/cdnjs/v/angular-vertxbus.svg)](https://cdnjs.com/libraries/angular-vertxbus) [![Build Status](https://img.shields.io/travis/knalli/angular-vertxbus.svg)](https://travis-ci.org/knalli/angular-vertxbus) [![Sauce Test Status](https://saucelabs.com/buildstatus/knalli-angular-vertxbus)](https://saucelabs.com/u/angular-vertxbus) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](http://gruntjs.com/) [![Greenkeeper badge](https://badges.greenkeeper.io/knalli/angular-vertxbus.svg)](https://greenkeeper.io/)\n\nClient side library using VertX Event Bus as an Angular Service module\n\n## Status\n\n| Branch | Stability | Status |\n| --- | --- | --- |\n| Canary | unstable | [![Build Status](https://travis-ci.org/knalli/angular-vertxbus.svg?branch=canary)](https://travis-ci.org/knalli/angular-vertxbus) |\n| Master | stable | [![Build Status](https://travis-ci.org/knalli/angular-vertxbus.svg?branch=master)](https://travis-ci.org/knalli/angular-vertxbus) |\n\nAutomatic tests running against the latest version of the major browsers:\n\n[![Sauce Test Status](https://saucelabs.com/browser-matrix/angular-vertxbus.svg)](https://saucelabs.com/)\n\n\n## How to get\n\nEither download it manually or install it automatically with Bower `bower install -D angular-vertxbus` or npm `npm install -D angular-vertxbus`.\n\nThen only import `dist/angular-vertxbus.js` or `dist/angular-vertxbus.min.js`. The file itself comes with a CJS header.\n\nAlternatively you can use the cdnjs: [cdnjs.com/libraries/angular-vertxbus](https://cdnjs.com/libraries/angular-vertxbus).\n\n## Dependencies\n\n### JavaScript (Polyfill)\n\nThe source code is written using newer JavaScript ([ECMAScript 2015+](https://babeljs.io/learn-es2015/))and is using the JavaScript transpiler [BabelJS](https://babeljs.io).\n\nDepending on your target clients, you probably need to include a browser polyfill (for ES5 clients). BabelJS itself\nrecommends the [requirement of its own polyfill](https://babeljs.io/docs/usage/polyfill/). Either you use the explained\nway using npm modules and/or browserify, or you can use the alternative artifact variant `dist/angular-vertxbus.withpolyfill.js`.\n\n### AngularJS 1.x\n\nThis library performs integration tests for *AngularJS 1.2 - 1.6*!\n\n### Vert.x\n\nThis library is being developed against the `eventbus.js` from Vert.x 3.\n\n## How to use\n\n### API\n\nAn [Api Documentation](https://knalli.github.io/angular-vertxbus.docs/docs/#/api/knalli.angular-vertxbus) is available.\n\n### Quick start\n\nYou have to define the module dependency, this module is named `knalli.angular-vertxbus`.\n\n```javascript\nangular.module('app', ['knalli.angular-vertxbus'])\n  .controller('MyCtrl', function(vertxEventBus, vertxEventBusService) {\n\n    // using the EventBus directly\n    vertxEventBus.send('my.address', {data: 123});\n\n    // using the service\n    vertxEventBusService.send('my.address', {data: 123})\n\n  });\n```\n\n### Consume messages\n\n```javascript\nvertxEventBusService.on('myaddress', function(err, message) {\n  console.log('Received a message: ', message);\n});\n```\n\n### Publish a message\n\n```javascript\nvertxEventBusService.publish('myaddress', {data: 123});\n```\n\n### Send a message\n\n```javascript\nvertxEventBusService.send('myaddress', {data: 123})\n  .then(function(reply) {\n    console.log('A reply received: ', reply);\n  })\n  .catch(function() {\n    console.warn('No message');\n  });\n\n// The \"No reply message found\" is controlled via a timeout (default 10000ms)\nvertxEventBusService.send('myaddress', {data: 123}, {timeout: 3000})\n  .then(function(reply) {\n    console.log('A reply received: ', reply);\n  })\n  .catch(function() {\n    console.warn('No message within 3 seconds');\n  });\n\n// If the reply is an error, this will be the payload\nvertxEventBusService.send('myaddress', {data: 123})\n  .then(function(reply) {\n    console.log('A reply received: ', reply);\n  })\n  .catch(function(err) {\n    console.warn(err);\n  });\n```\n\n## Advanced configuration\n\nThe module has some advanced configuration options. Perhaps you do not have to change them, but at least you should know them!\n\nEach module configuration option must be defined in the `run` phase, i.e.:\n\n```javascript\nangular.module('app', ['knalli.angular-vertxbus'])\n  .config(function(vertxEventBusProvider) {\n    vertxEventBusProvider\n      .enable()\n      .useReconnect()\n      .useUrlServer('http://live.example.org:8888');\n  });\n```\n\nPlease have a look at the API documentation for [vertxEventBusProvider](https://knalli.github.io/angular-vertxbus.docs/docs/#/api/knalli.angular-vertxbus.vertxEventBusProvider)\nand [vertxEventBusServiceProvider](https://knalli.github.io/angular-vertxbus.docs/docs/#/api/knalli.angular-vertxbus.vertxEventBusServiceProvider) for further options.\n\n## Architecture details\n\nThe module contains two items: the stub holder `vertxEventBus` for the Vert.x EventBus and a more comfortbale high level service `vertxEventBusService`.\n\n*The stub* is required because the Vert.x Event Bus cannot handle a reconnect. The reason is the underlaying SockJS which cannot handle a reconnect, too. A reconnect means to create a new instance of `SockJS`, therefore a new instance of `EventBus`. The stub ensures only one single instance exists. Otherwise a global module was not possible.\n\nMore or less the stub supports the same API calls like the original `EventBus`.\n\nBased on the stub, the *high level service* `vertxEventBusService` detects disconnects, handles reconnects and ensures re-registrations of subscriptions. Furthermore, the service provides some neat aliases for the usage of handlers.\n\n```javascript\n// Same as EventBus.registerHandler()\nservice.registerHandler('myaddress', callback);\nservice.on('myaddress', callback);\nservice.addListener('myaddress', callback);\n\n// Same as EventBus.unregisterHandler()\nservice.unregisterHandler('myaddress', callback);\nservice.un('myaddress', callback);\nservice.removeListener('myaddress', callback);\n\n// Same as EventBus.send()\nservice.send('myaddress', data)\n\n// Same as EventBus.publish\nservice.publish('myaddress', data)\nservice.emit('myaddress', data)\n\n// Same as EventBus.readyState()\nservice.readyState()\n```\n\nIn addition to this, when sending a message with an expected reply:\n\n```javascript\n// Same as EventBus.send() but with a promise\nservice.send('myaddress', data)\n  .then(function(reply) {})\n  .catch(function(err) {})\n```\n\nFor each connect or disconnect, a global broadcast will be emitted (on `$rootScope` with `'vertx-eventbus.system.connected'`, `'vertx-eventbus.system.disconnected'`)\n\n## Tests\n\n### Unit tests\n\nNote: Check that dependencies are be installed (`npm install`).\n\nThe *unit tests* are available with `npm test` which is actually a shortcut for `grunt test`. It performs tests under the current primary target version of AngularJS. Use `npm run test-scopes` for testing other scoped versions as well.\n\n### Local test environment\n\nNote: Check that dependencies are be installed (`npm install`).\n\nThe *local test environment* starts and utilizes a full Vert.x node and a NodeJS based web server.\n\n**Easy:** Just run `npm run -s start-server` and open `http://localhost:3000/` in your preferred browser.\n\nIf you have changed something, just invoke `npm run -s compile` in parallel and refresh the browser.\n\nAlternatively:\n\n1. `npm run install-it-vertx-server` downloads and installs a Vert.x locally. This will store a cached download artifact at `test/e2e//vertx/`.\n2. `npm run start-it-vertx-server` starts an Vert.x on port `8080`.\n3. `npm run start-it-web-server` starts a web server on port `3000`.\n4. Ensure at least `npm run -s compile` has been invoked so there is a `dist/angular-vertxbus.js`.\n5. Open http://localhost:3000/ in your browser.\n\n## License\n\nCopyright 2017 by Jan Philipp. Licensed under MIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknalli%2Fangular-vertxbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknalli%2Fangular-vertxbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknalli%2Fangular-vertxbus/lists"}