ngx-stomp
Support Stomp.js for Angular or Ionic
Installation
First install the stompjs library to support the browser stomp protocol.
$ npm install @stomp/stompjs --save
Then install this library to support Angular or Ionic
$ npm install ngx-stomp --save
Usage
If it's Angular project, modify in angular.json
or angular-cli.json
If it's Ionic project, first modify package.json, like this:
Create file copy.config
// path config/copy.config.jsmoduleexports =copyCropperjs:src: "{{ROOT}}/node_modules/@stomp/stompjs/lib/stomp.min.js"dest: "{{BUILD}}";
Add stomp.min.js
the index.html
<!-- src/index.html -->
After that, Angular and Ionic use are the same.
Modify in the app.module.ts
;
Connect to the stomp service
...constructorprivate stomp: NgxStompServicethis.stomp.connect;...
Subscribe to the message queue
this.stomp.ready.subscribe;
Destory service and disconnect
this.stomp.destory;