1.0.7 • Published 5 years ago
ezpubsub v1.0.7
EzPubSub
Simple Pub/Sub Messaging
Installation
npm install --save ezpubsubThen:
import EzPubSub from 'ezpubsub';If you're not using ES6 modules:
let EzPubSub = require('ezpubsub')CDN
<script src="https://cdn.jsdelivr.net/npm/ezpubsub/dist/ezpubsub.min.js"></script>Vue
import VueEzPubSub from 'ezpubsub/vue'Usage
Initialization
let client = new EzPubSub('your-app-id',{
key: 'your-app-key',
secret: 'your-app-secret',
cluster: 'your-app-cluster'
});// Vue.js
Vue.use(VueEzPubSub,'your-app-id',{
key: 'your-app-key',
secret: 'your-app-secret',
cluster: 'your-app-cluster'
})You can get your app_id, key, secret and cluster from the EzPubSub.
Subscribe Channel
client.subscribeChannel('/my-channel', function(message) {
alert(JSON.stringify(message));
});// Vue.js
this.$ezpub.subscribeChannel('/my-channel', function(message) {
alert(JSON.stringify(message));
});Publish Channel
client.publishChannel('/my-channel', {
text: 'Hello world'
});// Vue.js
this.$ezpub.publishChannel('/my-channel', {
text: 'Hello world'
});Credits
- All Contributors
License
The MIT License (MIT). Please see License File for more information.