Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eseom/vue-nes

vuejs hapi nes plugin
https://github.com/eseom/vue-nes

hapi nes vue websocket

Last synced: 20 days ago
JSON representation

vuejs hapi nes plugin

Awesome Lists containing this project

README

        

# vue-nes

> vue plugin support for hapi-nes

[![npm version][npm-badge]][npm-url]

You can use this plugin to add NES(websocket for hapijs) support to your vue application. The messages pass through the synced store, and you can get those messages at anywhere.

# requirements
- vuex

# Usage

Example:
```js
// vuejs boot file
import VueNes from 'vue-nes'

// usually websocket url is localhost:
const wsUrl = `ws${window.location.protocol === 'https:' ? 's' : ''}://${window.location.host}`
Vue.use(VueNes, { wsUrl, store } )

// store generator
import { vuexModule as socketVuexModule } from 'vue-nes'

const store = new Vuex.Store({
actions,
getters,
modules: {
.
.
nes: socketVuexModule,
.
.
},
strict: true,
})

// in components
// Register component scoped subscriptions
// We can get messages from store when we're in the component


{{message.code}}

export default {
.
.
nes: {
subscribe: [
'/item/6', // you can receive from this subscription on this component, and all child components.
],
},
.
.
computed: {
message() {
this.$store.state.nes.message // you can get broadcast messages from server at here
}
},
}

```

# development
```
git clone https://github.com/eseom/vue-nes
cd vue-nes
yarn
yarn link
yarn watch

# (and open a new terminal)
cd /path/to/your_vue_project
yarn link vue-nes

# enjoy it
```

[npm-url]: https://www.npmjs.com/package/vue-nes
[npm-badge]: https://img.shields.io/npm/v/vue-nes.svg