All Projects → knalli → Angular Vertxbus

knalli / Angular Vertxbus

Licence: mit
AngularJS 1.x service wrapper for the Vert.x Event Bus

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Angular Vertxbus

Mean Stack Angular6 Crud Example
MEAN Stack Angular 6 CRUD Web Application
Stars: ✭ 69 (-11.54%)
Mutual labels:  angularjs
Angular2
Angular 2 Seed
Stars: ✭ 75 (-3.85%)
Mutual labels:  angularjs
Vonage Java Sdk
Vonage Server SDK for Java. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 75 (-3.85%)
Mutual labels:  messaging
Humusamqp
PHP 7 AMQP library
Stars: ✭ 70 (-10.26%)
Mutual labels:  messaging
Element Rpm
Providing the Element messaging desktop client packaged for the Fedora, Red Hat(IBM), and OpenSUSE families of linux desktop operating systems.
Stars: ✭ 73 (-6.41%)
Mutual labels:  messaging
Qmchatviewcontroller Ios
An elegant ready to go chat view controller for iOS applications
Stars: ✭ 75 (-3.85%)
Mutual labels:  messaging
Pushraven
A simple Java library to interface with Firebase Cloud Messaging (FCM) API. Pushraven allows you to push notifications to clients in very few lines of code.
Stars: ✭ 67 (-14.1%)
Mutual labels:  messaging
Openbrews
A cross-platform open source app to help you brew beer.
Stars: ✭ 78 (+0%)
Mutual labels:  angularjs
Eeh Navigation
An AngularJS menu module.
Stars: ✭ 74 (-5.13%)
Mutual labels:  angularjs
Applozic Web Plugin
Javascript (jQuery) Real Time Chat & Messaging plugin
Stars: ✭ 76 (-2.56%)
Mutual labels:  messaging
Angular Validate
Painless form validation for AngularJS. Powered by the jQuery Validation Plugin.
Stars: ✭ 71 (-8.97%)
Mutual labels:  angularjs
Generator Angm
AngularJS Yeoman Generator to help you getting started with a new project based on AngularJS and Angular Material to build large scale applications.
Stars: ✭ 72 (-7.69%)
Mutual labels:  angularjs
Android Kotlin Chat App
Open-source Voice & Video Calling and Text Chat App for Kotlin (Android)
Stars: ✭ 76 (-2.56%)
Mutual labels:  messaging
Angular Responsive Tables
Make your HTML tables look great on every device
Stars: ✭ 69 (-11.54%)
Mutual labels:  angularjs
Angular2 Demo
A simple demo for Angular 2
Stars: ✭ 77 (-1.28%)
Mutual labels:  angularjs
Alpakka
Alpakka is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Akka.
Stars: ✭ 1,154 (+1379.49%)
Mutual labels:  messaging
Component Pattern For Angular Js 1 X
Example of implementation of Component pattern for Angular JS 1.X using ES6 & Webpack
Stars: ✭ 75 (-3.85%)
Mutual labels:  angularjs
Sfs
The distributed object storage server used by PitchPoint Solutions to securely store billions of large and small files using minimal resources. Object data is stored in replicated volumes implemented like Facebooks Haystack Object Store. Object metadata which essentially maps an object name to a volume position is stored in an elasticsearch index.
Stars: ✭ 78 (+0%)
Mutual labels:  vertx
Angular2 Contacts Demo
Angular 2 (ng2) 通讯录例子
Stars: ✭ 78 (+0%)
Mutual labels:  angularjs
Iwanttoworkatnuveo
Você é pessoa desenvolvedora? Quer trabalhar com Inteligência artificial? Esse repositório é pra você!
Stars: ✭ 76 (-2.56%)
Mutual labels:  angularjs

angular-vertxbus

Bower version npm version cdnjs Build Status Sauce Test Status Built with Grunt Greenkeeper badge

Client side library using VertX Event Bus as an Angular Service module

Status

Branch Stability Status
Canary unstable Build Status
Master stable Build Status

Automatic tests running against the latest version of the major browsers:

Sauce Test Status

How to get

Either download it manually or install it automatically with Bower bower install -D angular-vertxbus or npm npm install -D angular-vertxbus.

Then only import dist/angular-vertxbus.js or dist/angular-vertxbus.min.js. The file itself comes with a CJS header.

Alternatively you can use the cdnjs: cdnjs.com/libraries/angular-vertxbus.

Dependencies

JavaScript (Polyfill)

The source code is written using newer JavaScript (ECMAScript 2015+)and is using the JavaScript transpiler BabelJS.

Depending on your target clients, you probably need to include a browser polyfill (for ES5 clients). BabelJS itself recommends the requirement of its own polyfill. Either you use the explained way using npm modules and/or browserify, or you can use the alternative artifact variant dist/angular-vertxbus.withpolyfill.js.

AngularJS 1.x

This library performs integration tests for AngularJS 1.2 - 1.6!

Vert.x

This library is being developed against the eventbus.js from Vert.x 3.

How to use

API

An Api Documentation is available.

Quick start

You have to define the module dependency, this module is named knalli.angular-vertxbus.

angular.module('app', ['knalli.angular-vertxbus'])
  .controller('MyCtrl', function(vertxEventBus, vertxEventBusService) {

    // using the EventBus directly
    vertxEventBus.send('my.address', {data: 123});

    // using the service
    vertxEventBusService.send('my.address', {data: 123})

  });

Consume messages

vertxEventBusService.on('myaddress', function(err, message) {
  console.log('Received a message: ', message);
});

Publish a message

vertxEventBusService.publish('myaddress', {data: 123});

Send a message

vertxEventBusService.send('myaddress', {data: 123})
  .then(function(reply) {
    console.log('A reply received: ', reply);
  })
  .catch(function() {
    console.warn('No message');
  });

// The "No reply message found" is controlled via a timeout (default 10000ms)
vertxEventBusService.send('myaddress', {data: 123}, {timeout: 3000})
  .then(function(reply) {
    console.log('A reply received: ', reply);
  })
  .catch(function() {
    console.warn('No message within 3 seconds');
  });

// If the reply is an error, this will be the payload
vertxEventBusService.send('myaddress', {data: 123})
  .then(function(reply) {
    console.log('A reply received: ', reply);
  })
  .catch(function(err) {
    console.warn(err);
  });

Advanced configuration

The module has some advanced configuration options. Perhaps you do not have to change them, but at least you should know them!

Each module configuration option must be defined in the run phase, i.e.:

angular.module('app', ['knalli.angular-vertxbus'])
  .config(function(vertxEventBusProvider) {
    vertxEventBusProvider
      .enable()
      .useReconnect()
      .useUrlServer('http://live.example.org:8888');
  });

Please have a look at the API documentation for vertxEventBusProvider and vertxEventBusServiceProvider for further options.

Architecture details

The module contains two items: the stub holder vertxEventBus for the Vert.x EventBus and a more comfortbale high level service vertxEventBusService.

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.

More or less the stub supports the same API calls like the original EventBus.

Based 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.

// Same as EventBus.registerHandler()
service.registerHandler('myaddress', callback);
service.on('myaddress', callback);
service.addListener('myaddress', callback);

// Same as EventBus.unregisterHandler()
service.unregisterHandler('myaddress', callback);
service.un('myaddress', callback);
service.removeListener('myaddress', callback);

// Same as EventBus.send()
service.send('myaddress', data)

// Same as EventBus.publish
service.publish('myaddress', data)
service.emit('myaddress', data)

// Same as EventBus.readyState()
service.readyState()

In addition to this, when sending a message with an expected reply:

// Same as EventBus.send() but with a promise
service.send('myaddress', data)
  .then(function(reply) {})
  .catch(function(err) {})

For each connect or disconnect, a global broadcast will be emitted (on $rootScope with 'vertx-eventbus.system.connected', 'vertx-eventbus.system.disconnected')

Tests

Unit tests

Note: Check that dependencies are be installed (npm install).

The 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.

Local test environment

Note: Check that dependencies are be installed (npm install).

The local test environment starts and utilizes a full Vert.x node and a NodeJS based web server.

Easy: Just run npm run -s start-server and open http://localhost:3000/ in your preferred browser.

If you have changed something, just invoke npm run -s compile in parallel and refresh the browser.

Alternatively:

  1. npm run install-it-vertx-server downloads and installs a Vert.x locally. This will store a cached download artifact at test/e2e//vertx/.
  2. npm run start-it-vertx-server starts an Vert.x on port 8080.
  3. npm run start-it-web-server starts a web server on port 3000.
  4. Ensure at least npm run -s compile has been invoked so there is a dist/angular-vertxbus.js.
  5. Open http://localhost:3000/ in your browser.

License

Copyright 2017 by Jan Philipp. Licensed under MIT.

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].