# vue-coe-socketio

> socketio

Latest version **0.1.5** (published 2018-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-coe-socketio
pnpm add vue-coe-socketio
yarn add vue-coe-socketio
bun add vue-coe-socketio
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2018-09-20 |
| First published | 2018-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 149.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Vinicius Azevedo |
| Maintainers | viniazvd |
| Keywords | socket, websocket, socketio-client, js, vue, vuejs |

## Links

- npm: https://www.npmjs.com/package/vue-coe-socketio
- Repository: https://github.com/viniazvd/vue-coe-socketio
- Homepage: https://github.com/viniazvd/vue-coe-socketio#readme
- Issues: https://github.com/viniazvd/vue-coe-socketio/issues
- npm.io page: https://npm.io/package/vue-coe-socketio

## Dependencies (1)

- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.1.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.5 (latest) — 2018-09-20
- 0.1.4 — 2018-09-20
- 0.1.3 — 2018-09-18
- 0.1.1 — 2018-09-18
- 0.1.0 — 2018-09-17

## README

<h1 align="center">vue-coe-socketio ✅</h1>

<p align="center">
  <q>based on <b>socketio-client</b></q>
</p>

<p align="center">
  <a href="#"><img src="https://img.shields.io/npm/l/vuelidation.svg" alt="License" target="_blank"></a>
</p>

<p align="center">
  ✨ <a href="https://codesandbox.io/s/github/viniazvd/chat-websocket/tree/master/ws-client">Example</a>✨
</p>

**Install**

`yarn add vue-coe-socketio@latest`

**Include Plugin**
```javascript
import Vue from 'vue'

import VueCoeWebSocket from 'vue-coe-socketio'

Vue.use(VueCoeWebSocket, '127.0.0.1:4000')
```

**Example usage**
```vue
<template>
  <div id="app">
    <div>
      <h3>Chat</h3>
      <div>
        <div v-for="(msg, index) in messages" :key="index">
          <p>{{ msg.user }}: {{ msg.message }}</p>
        </div>
      </div>
    </div>

    <div>
      <form @submit.prevent="sendMessage">
        <div>
          <label for="user">User:</label>
          <input type="text" v-model="user">
        </div>
        <div>
          <label for="message">Message:</label>
          <input type="text" v-model="message">
        </div>
        <button type="submit">Send</button>
      </form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'chat',

  data () {
    return {
      user: '',
      message: '',
      messages: []
    }
  },

  socket: {
    channel: '/main',

    events: {
      IS_CONNECTED (status) {
        if (status === 'connected') {
          console.log('ws is: ', status)
        } else {
          console.warn('you are not connected')
        }
      },

      NEW_MESSAGE (msg) {
        this.messages = [ ...this.messages, msg ]
      }
    }
  },

  methods: {
    sendMessage () {
      const payload = { user: this.user, message: this.message }

      this.$socket.emit('SEND_MESSAGE', payload)

      this.message = ''
    }
  },

  mounted () {
    this.$socket.emit('CONNECT')
  }
}
</script>
```

---
_Source: https://npm.io/package/vue-coe-socketio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
