2
0
mirror of https://github.com/tenrok/vue-native-websocket.git synced 2026-06-01 22:14:05 +03:00

Fix observer mutation name when format: json is used (#9)

According to the documentation: "If there is a .mutation value in the
response data, the corresponding mutation is called with the name
SOCKET_[mutation value]"

However when event data does not contains .mutation value mutation is
null, so the mutation is not find in the store.
This commit is contained in:
Nicolas Meylan
2017-07-24 21:49:43 +02:00
committed by Nathan
parent ef8a327c70
commit ace2bf5d91
+3 -2
View File
@@ -34,8 +34,9 @@ export default class {
let msg = event
if (this.format === 'json' && event.data) {
msg = JSON.parse(event.data)
target = [msg.namespace || '', msg.mutation].filter((e) => !!e).join('/')
if (msg.action) {
if (msg.mutation) {
target = [msg.namespace || '', msg.mutation].filter((e) => !!e).join('/')
} else if (msg.action) {
method = 'dispatch'
target = msg.action
}