mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
Set .sockets to event callbacks
This commit is contained in:
parent
8fe037f721
commit
9d7c791033
1 changed files with 3 additions and 0 deletions
|
@ -19,12 +19,14 @@ export default {
|
|||
Object.defineProperty(this.$options.sockets, 'on', {
|
||||
value: (label, callback) => {
|
||||
Emitter.addListener(label, callback, this);
|
||||
this.$options.sockets[label] = callback;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(this.$options.sockets, 'off', {
|
||||
value: (label, callback) => {
|
||||
Emitter.removeListener(label, callback, this);
|
||||
delete this.$options.sockets[label];
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -40,6 +42,7 @@ export default {
|
|||
if(sockets){
|
||||
Object.keys(sockets).forEach((key) => {
|
||||
Emitter.removeListener(key, sockets[key], this);
|
||||
delete this.$options.sockets[key];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue