0.1.2 • Published 7 years ago

vue-nes v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

vue-nes

vue plugin support for hapi-nes

npm version

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:

// 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
<template>
  <div>
    {{message.code}}
  </div>
</template>

<script>
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
    }
  },
}
</script>

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
0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago