ng-stomp

WebJar for ng-stomp

License

License

MIT
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

ng-stomp
Last Version

Last Version

0.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

ng-stomp
WebJar for ng-stomp
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/beevelop/ng-stomp

Download ng-stomp

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/ng-stomp/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>ng-stomp</artifactId>
    <version>0.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/ng-stomp/
implementation 'org.webjars.bower:ng-stomp:0.5.0'
// https://jarcasting.com/artifacts/org.webjars.bower/ng-stomp/
implementation ("org.webjars.bower:ng-stomp:0.5.0")
'org.webjars.bower:ng-stomp:jar:0.5.0'
<dependency org="org.webjars.bower" name="ng-stomp" rev="0.5.0">
  <artifact name="ng-stomp" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='ng-stomp', version='0.5.0')
)
libraryDependencies += "org.webjars.bower" % "ng-stomp" % "0.5.0"
[org.webjars.bower/ng-stomp "0.5.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.bower : sockjs-client jar [1.1.1]
org.webjars.bower : stomp-websocket jar [2.3.4]

Project Modules

There are no modules declared in this project.

npm Travis Maintainability Gemnasium js-standard-style Beevelop

ngStomp

STOMP promised for AngularJS

Installation

Install via npm:

npm install --save ng-stomp

Add standalone version (dependencies included) to your HTML file

<script src="node_modules/ng-stomp/dist/ng-stomp.standalone.min.js"></script>

Or add SockJS + STOMP + (minified) Stompie individually:

<script src="node_modules/sockjs/sockjs.min.js"></script>
<script src="node_modules/@stomp/stompjs/lib/stomp.min.js"></script>
<script src="node_modules/ng-stomp/dist/ng-stomp.min.js"></script>

Usage

Inject it in your controller:

angular
  // Declare ngStomp as a dependency for you module
  .module('app', ['ngStomp'])

  // use $stomp in your controllers, services, directives,...
  .controller('Ctrl', function ($stomp, $scope, $log) {
    $stomp.setDebug(function (args) {
      $log.debug(args)
    })

    $stomp
      .connect('/endpoint', connectHeaders)

      // frame = CONNECTED headers
      .then(function (frame) {
        var subscription = $stomp.subscribe('/dest', function (payload, headers, res) {
          $scope.payload = payload
        }, {
          'headers': 'are awesome'
        })

        // Unsubscribe
        subscription.unsubscribe()

        // Send message
        $stomp.send('/dest', {
          message: 'body'
        }, {
          priority: 9,
          custom: 42 // Custom Headers
        })

        // Disconnect
        $stomp.disconnect().then(function () {
          $log.info('disconnected')
        })
      })
  })

API-Docs (TBD)

  • setDebug(callback)
  • connect(endpoint, headers)
  • disconnect
  • subscribe(destination, callback, headers)
  • on(destination, callback, headers)
  • unsubscribe(subscription)
  • off(subscription)
  • send(destination, body, headers)

Breaking changes

  • Bower support has been removed from v0.5.0 onwards. Please switch to npm / yarn.

Versions

Version
0.5.0
0.4.0
0.3.0
0.2.0