You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Vue-Socket.io/vue-socketio.min.js

31 lines
1.5 KiB
JavaScript

!function () {
var o = "function" == typeof require ? require("socket.io-client") : window.io;
if (!o)throw new Error("[Vue-Socket.io] cannot locate Socket.io");
var n = {
install: function (n, t) {
if (!t)throw new Error("[Vue-Socket.io] cannot locate connection");
if ("string" == typeof t)var e = o(t); else if ("object" == typeof t)var e = t;
var c = e.onevent;
e.onevent = function (o) {
var n = o.data || [];
c.call(this, o), o.data = ["*"].concat(n), c.call(this, o)
};
var i = ["connect", "error", "disconnect", "reconnect", "reconnect_attempt", "reconnecting", "reconnect_error", "reconnect_failed"];
n.mixin({
created: function () {
var o = this;
this.$options.hasOwnProperty("sockets") && (e.on("*", function (n, t) {
o.$options.sockets.hasOwnProperty(n) && o.$options.sockets[n].call(o, t)
}), i.forEach(function (n) {
e.on(n, function (t) {
o.$options.sockets.hasOwnProperty(n) && o.$options.sockets[n].call(o, t)
})
})), this.$socket = e
}
})
}
};
"object" == typeof exports ? module.exports = n : "function" == typeof define && define.amd ? define([], function () {
return n
}) : window.Vue && (window.VueSocketio = n)
}();