From ace2bf5d9147a9bce35cb7452c84537c87a3446b Mon Sep 17 00:00:00 2001 From: Nicolas Meylan Date: Mon, 24 Jul 2017 21:49:43 +0200 Subject: [PATCH] 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. --- src/Observer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Observer.js b/src/Observer.js index 38038b8..f656215 100755 --- a/src/Observer.js +++ b/src/Observer.js @@ -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 }