title: Spring stomp websockets with vue.js
body: <p>I'm trying to use Spring websockets (STOMP) with Vue but can't figure out how to do it or if it's even possible. My websockets work with plain JS but when i try with Vue i get stuck. Here is my vue code:</p>
  
  <pre><code>var app = new Vue({
  el: '#app',
  data: {
      stompClient: null,
      gold: 0
  },
  methods: {
      sendEvent: function () {
          this.stompClient.send("/app/hello", {}, JSON.stringify({'name': $("#name").val()}));
      }
  },
  created: function () {
      this.stompClient = Stomp.over(new SockJS('/gs-guide-websocket'));
      this.stompClient.connect()
      this.stompClient.subscribe('/topic/greetings', function (greeting) {
          console.log(JSON.parse(greeting.body).content);
      });
  },
  </code></pre>
  
  <p>})</p>
  
  <p>My connect and send function is working and i can see the message in the backend but the problem is the subscribe function. It needs a callback function but this never fire. I have also tried to create a method in vue and call that</p>
  
  <pre><code>this.stompClient.subscribe('/topic/greetings', vueFunc())
  </code></pre>
  
  <p>but that does not work either. I have found some library at <a href="https://github.com/FlySkyBear/vue-stomp" rel="noreferrer">https://github.com/FlySkyBear/vue-stomp</a> but I can't figure out how to use that and it looks really messy. I rather use plain JS then.</p>
  
  <p>Anyone got an solution? Thanks</p>