@quangdao/vue-signalr
Vue SignalR Plugin
SignalR plugin for Vue 3.
Quick Start
For more detailed instructions, check out the wiki at https://github.com/quangdaon/vue-signalr/wiki.
Installation
This package is available on npm via:
npm install --save @quangdao/vue-signalr
To install in Vue 3:
import { createApp } from 'vue';
import { VueSignalR } from '@quangdao/vue-signalr';
import App from './App.vue';
createApp(App)
.use(VueSignalR, { url: 'http://localhost:5000/signalr' })
.mount('#app');
Usage
This plugin provides a composable function to inject the SignalR service. The service exposes a few methods from the SignalR connection to support your app.
import { inject } from 'vue';
import { useSignalR } from '@quangdao/vue-signalr';
interface MyObject {
prop: string;
}
// Optional Tokens
// Learn More: https://github.com/quangdaon/vue-signalr/wiki/03.-Usage#tokens
const SendMessage: HubCommandToken<MyObject> = 'SendMessage';
const MessageReceived: HubEventToken<MyObject> = 'MessageReceived';
export default {
setup() {
// Inject the service
const signalr = useSignalR();
// Listen to the "MessageReceived" event
signalr.on(MessageReceived, () => doSomething());
// Send a "SendMessage" payload to the hub
signalr.send(SendMessage, { prop: 'Hello world!' });
// Invoke "SendMessage" and wait for a response
signalr.invoke(SendMessage, { prop: 'Hello world!' })
.then(() => doSomething())
}
};
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.1 | >=3 <4 | MIT | |
| 1.0.0 | >=3 <4 | ISC | |
| 0.0.11 | >=3 <4 | ISC | |
| 0.0.10 | >=3 <4 | ISC | |
| 0.0.9 | ^3.1.2 | ISC | |
| 0.0.8 | ^3.1.2 | ISC | |
| 0.0.7 | ^3.1.2 | ISC | |
| 0.0.6 | ^3.1.2 | ISC | |
| 0.0.5 | ^3.1.2 | ISC | |
| 0.0.4 | ^3.1.2 | ISC | |
| 0.0.3 | ^3.1.2 | ISC | |
| 0.0.2 | ^3.1.2 | ISC | |
| 0.0.1 | ^3.1.2 | ISC |
Pre-releases (1)
| Version | Released | Vue | License |
|---|---|---|---|
| 1.1.0-alpha.0 | >=3 <4 | MIT |
