JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q51686F
  • License GPL-3.0-or-later

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

Package Exports

  • nuxt-wamp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nuxt-wamp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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