vue-ws
TypeScript icon, indicating that this package has built-in type declarations

0.0.2-beta • Public • Published

Vue-Socket

Introduction

Vue-socket is a websocket plugin for Vue.js. It inject websocket lifecycle events into components, like open, close, error, and also it simplify event binding of message event. Support for Typescript.

Warning

The data structure of message event's data property should be like {type: "ping", data: {}}.

Install

npm install vue-ws

Usage

entry file

import VueSocket from "vue-ws";
Vue.use(VueSocket);

component

import Vue from "vue";
export default Vue.extend({
    onWebSocketOpen(){
        console.log("opened");
    },
    onWebSocketMsg: {
        ping(){
            console.log("pong");
        }
    }
});

License

This package is published under MIT license.

Readme

Keywords

Package Sidebar

Install

npm i vue-ws

Weekly Downloads

1

Version

0.0.2-beta

License

MIT

Unpacked Size

60.5 kB

Total Files

6

Last publish

Collaborators

  • elgine