Skip to content

Commit 432b1de

Browse files
authored
Merge pull request nathantsoi#66 from gbtux/vuex_socket
Vuex socket
2 parents 4420299 + 690b6ca commit 432b1de

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export default new Vuex.Store({
142142
},
143143
mutations:{
144144
SOCKET_ONOPEN (state, event) {
145+
Vue.prototype.$socket = event.currentTarget
145146
state.socket.isConnected = true
146147
},
147148
SOCKET_ONCLOSE (state, event) {
@@ -161,6 +162,13 @@ export default new Vuex.Store({
161162
SOCKET_RECONNECT_ERROR(state) {
162163
state.socket.reconnectError = true;
163164
},
165+
},
166+
actions: {
167+
sendMessage: function(context, message) {
168+
.....
169+
Vue.prototype.$socket.send(message)
170+
.....
171+
}
164172
}
165173
})
166174
```

0 commit comments

Comments
 (0)