Skip to content

Commit b7f3a45

Browse files
authored
Merge pull request nathantsoi#65 from weglov/feature/fix-reconnection
Fix reconnection ws instance
2 parents a31cb5e + dad451d commit b7f3a45

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This package is [semantic versioned](http://semver.org/)
44

5+
## 2.0.9
6+
- [bugfix]: fixed reconnection
7+
58
## 2.0.8
69
- [feature]: custom pass to store logic. Defaults to original passToStore code if no custom logic provided
710

dist/build.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-native-websocket",
3-
"version": "2.0.8",
3+
"version": "2.0.9",
44
"description": "native websocket implemantation for vuejs and vuex",
55
"main": "dist/build.js",
66
"scripts": {

src/Main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export default {
88

99
let observer = null
1010

11+
opts.$setInstance = (wsInstance) => {
12+
Vue.prototype.$socket = wsInstance
13+
}
14+
1115
if (opts.connectManually) {
1216
Vue.prototype.$connect = () => {
1317
observer = new Observer(connection, opts)

src/Observer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ export default class {
5555

5656
if (this.store) { this.passToStore('SOCKET_' + eventType, event) }
5757

58-
if (this.reconnection && eventType === 'onopen') { this.reconnectionCount = 0 }
58+
if (this.reconnection && eventType === 'onopen') {
59+
this.opts.$setInstance(event.currentTarget)
60+
this.reconnectionCount = 0
61+
}
5962

6063
if (this.reconnection && eventType === 'onclose') { this.reconnect() }
6164
}

0 commit comments

Comments
 (0)