lazos
lazos

Reputation: 21

Integration AutobahnJS with Vue.js

I'm looking for an easy way to integrate Vue.js with AutobahnJS. I've already checked this repo for guidance/template, but my main problem is that Autobahn has two layers of "wait":

  1. First you create a Connection/Session instance
  2. You wait for it to connect (maybe even retry N times)
  3. Only after this can you access the session methods (subscribe/call/etc..)

With my limited JS knowledge (i'm a backend dev), i have two ideas:

  1. Create a global variable which will be assigned to the autobahn session after connection. This will surely cause cases where the var is not yet set, so I'd have to check it's existence every time I want to subscribe from a vue instance.
  2. Place the Vue init code into the Session connected callback, but then that would delay the whole application, which is obviously bad too.

I'm looking for a simple and efficient solution, not necessarily a full-fledged plugin (which I haven't found anywhere).

Any help/advice is appreciated!

Upvotes: 0

Views: 883

Answers (1)

lazos
lazos

Reputation: 21

I've been looking for a plugin like this: https://github.com/lajosbencz/vue-wamp

Plugin calls are deferred until autobahn Session is ready, unsubscribe and unregister are automatically called component-wise.

Upvotes: 2

Related Questions