1.0.3 • Published 4 years ago

nuxt-wamp v1.0.3

Weekly downloads
29
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

nuxt-wamp

WAMP Autobahn wrapper for Nuxt.js, served as an SSR compatible Module

See vue-wamp for more details

Features

  • Challenge callback for authentication is nuxt context aware
  • Easy usage through injection (global, component, config, app, store)
  • Subscriptions and registrations from a component will get automatically destroyed with the component

Example

// nuxt.config.js

// wrapper around onchallenge
const challenger = (context) => {
  const { req } = context
  // onchallenge itself
  return (session, method, extra) => {
    if(req) {
      // get some cookie?
      return 'server'
    } else {
      // get some cookie?
      return 'client'
    }
  }
}

export default {
  // ...
  modules: [
    // ...
    ['nuxt-wamp', { url: 'ws://localhost:4000/', realm: 'realm1', challenger }]
  ]
  // ...
}
<!-- component.vue -->

<script>
  export default {
    data() {
      return {
        time: '',
      }
    },
    wamp: {
      subscribe: {
        time(args, kwArgs, details) {
          this.time = args[0]
        }
      }
    },
    methods: {
      async trigger() {
        let res = await this.$wamp.call('trigger')
        console.log(res)
      },
    }
  }
</script>

<template>
  <div>
    <h1>{{ time }}</h1>
    <hr />
    <button @click="trigger">Boom!</button>
  </div>
</template>

Todo

  • Meaningful tests
  • Provide typing
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago