![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Since v2.0.0:
Since v3.0.0:
wampIsOpen
, wampIsConnected
and wampIsRetrying
are only available on the $root
component, to avoid data pollution. (Events are still emitted on all components)onopen {function}
onclose {function}
debug {boolean}
namespace {string}
: The namespace for the plugin, default: wamp
auto_reestablish {boolean}
: Automatically re-registers and re-subscribes after reconnectionauto_close_timeout {number}
: Will close the WS connection after amount of idle millisecondsnpm install --save vue-wamp
// entry.js
import VueWamp from 'vue-wamp'
Vue.use(VueWamp, {
url: 'ws://demo.crossbar.io/ws',
realm: 'realm1',
// change this in case of naming conflict
namespace: 'wamp',
// automatically re-registers and re-subscribes after reconnection (on by default)
auto_reestablish: true,
// automatically closes WS connection after amount of idle milliseconds (off by default)
auto_close_timeout: -1,
});
<template>
<div>
<span v-if="$root.wampIsOpen">Connected</span>
<span v-else-if="$root.wampIsRetrying">Retrying...</span>
<span v-else>Disconnected</span>
</div>
</template>
export default {
mounted() {
this.$on('$wamp.status', ({status, lastStatus, details}) => {});
this.$on('$wamp.opened', ({status, lastStatus, details}) => {});
this.$on('$wamp.closed', ({status, lastStatus, details}) => {});
this.$on('$wamp.retrying', ({status, lastStatus, details}) => {});
this.$on('$wamp.reconnected', ({status, lastStatus, details}) => {});
},
}
// component.vue
<template>
<div></div>
</template>
<script>
export default {
data() {
return {
someValue: 'foobar'
};
},
watch: {
someValue(val, old) {
this.$wamp.publish('some-topic', [], {val, old});
}
},
wamp: {
subscribe: {
'some-topic'(args, kwArgs, details) {
this.someValue = kwArgs.val;
},
'another-topic': {
acknowledge: true,
handler(args, kwArgs, details) {
// do stuff
}
}
},
register: {
'some-rpc'(args, kwArgs, details) {
return args[0] + ' I am useful!';
},
'another-rpc': {
invoke: 'random',
handler(args, kwArgs, details) {
// more stuff
}
}
}
}
}
</script>
Vue.$wamp.subscribe
, Vue.$wamp.publish
, Vue.$wamp.register
, Vue.$wamp.call
, Vue.$wamp.unsubscribe
, Vue.$wamp.unregister
// main.js
Vue.$wamp.subscribe('some-topic', function(args, kwArgs, details) {
// context is empty
console.log(this); // = null
}, {
acknowledge: true // option needed for promise
}).then(function(s) {
console.log('AutobahnJS Subscription object: ', s);
});
this.$wamp.subscribe
, this.$wamp.publish
, this.$wamp.register
, this.$wamp.call
, this.$wamp.unsubscribe
, this.$wamp.unregister
export default {
data() {
return {
foo: 'bar',
};
},
mounted() {
this.$wamp.subscribe('some-topic', function(args, kwArgs, details) {
// component context is available
return this.foo;
}, {
acknowledge: true // option needed for promise, automatically added
}).then(function(s) {
console.log('AutobahnJS Subscription object: ', s);
});
}
}
FAQs
WAMP protocol wrapper library for Vue
The npm package vue-3-wamp receives a total of 1 weekly downloads. As such, vue-3-wamp popularity was classified as not popular.
We found that vue-3-wamp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.