@bigin/vue-signalr

1.0.0 • Public • Published

vue-signalr

Installation

$ yarn add @bigin/vue-signalr

Get started

import Vue from "vue";
import VueSignalR from "vue-signalr";

Vue.use(VueSignalR, "SOCKET_URL");

new Vue({
  el: "#app",
  render: (h) => h(App),

  created() {
    this.$socket.start({
      log: false, // Active only in development for debugging.
    });
  },
});

Example with component

Vue.extend({

  ...

  methods: {

    someMethod() {
      this.$socket.invoke('socketName', payloadData)
        .then(response => {
          ...
        })
    }

    async someAsyncMethod() {
      const response = await this.$socket.invoke('socketName', payloadData)
      ...
    }

  },

  // Register your listener here.
  sockets: {

    // Equivalent of
    // signalrHubConnection.on('someEvent', (data) => this.someActionWithData(data))
    someEvent(data) {
      this.someActionWithData(data)
    }

    otherSomeEvent(data) {
      this.otheSomeActionWithOtherSomeData(data)
    }

  }

});

Readme

Keywords

none

Package Sidebar

Install

npm i @bigin/vue-signalr

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

15.3 kB

Total Files

3

Last publish

Collaborators

  • maichitam
  • tammai.bigin
  • trinhnguyen1103