Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate on open event handling for each vue component #64

Closed
danmash opened this issue Aug 20, 2018 · 2 comments
Closed

Separate on open event handling for each vue component #64

danmash opened this issue Aug 20, 2018 · 2 comments

Comments

@danmash
Copy link

danmash commented Aug 20, 2018

I want to separate onopen events for each vue component. Now I see alerts with 1 and 2 two times.
Is there a way to avoid this duplication?

Vue.use(VueNativeSock.default, wsPath, {
  reconnection: true,
  reconnectionAttempts: 5,
  reconnectionDelay: 3000,
  format: 'json',
});

var app1 = new Vue({
  created: function () {
    var vm = this;
    this.$options.sockets.onmessage = function (message) {
      vm.listen(message);
    };
    this.$options.sockets.onopen = function () {
      alert(1);
    }
  }
});

var app1 = new Vue({
  created: function () {
    var vm = this;
    this.$options.sockets.onmessage = function (message) {
      vm.listen(message);
    };
    this.$options.sockets.onopen = function () {
      alert(2);
    }
  }
});
@danmash danmash closed this as completed Aug 21, 2018
@ilyavaiser
Copy link

Why this closed?

@danmash
Copy link
Author

danmash commented Aug 27, 2018

can't reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants