From 240246ea132cc736c6eaa70ed79f2ec78d1d4636 Mon Sep 17 00:00:00 2001 From: Victor Chabbert Date: Sat, 20 May 2017 15:14:13 +0200 Subject: Add prettier and format js files --- frontend/src/utils/websocket.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'frontend/src/utils/websocket.js') diff --git a/frontend/src/utils/websocket.js b/frontend/src/utils/websocket.js index 1dde5397..6db91899 100644 --- a/frontend/src/utils/websocket.js +++ b/frontend/src/utils/websocket.js @@ -1,23 +1,28 @@ -import SockJS from 'sockjs-client' -import Stomp from 'webstomp-client' -import { eventChannel } from 'redux-saga' +import SockJS from "sockjs-client"; +import Stomp from "webstomp-client"; +import { eventChannel } from "redux-saga"; -const wsURL = '/seven-wonders-websocket' +const wsURL = "/seven-wonders-websocket"; -export const createWsConnection = (headers = {}) => new Promise((resolve, reject) => { +export const createWsConnection = (headers = {}) => + new Promise((resolve, reject) => { let socket = Stomp.over(new SockJS(wsURL), { debug: process.env.NODE_ENV !== "production" - }) - socket.connect(headers, (frame) => { - return resolve({ frame, socket }) - }, reject) -}) + }); + socket.connect( + headers, + frame => { + return resolve({ frame, socket }); + }, + reject + ); + }); export const createSubscriptionChannel = (socket, path) => { return eventChannel(emitter => { const receiveUsernameHandler = socket.subscribe(path, event => { - emitter(JSON.parse(event.body)) - }) - return () => receiveUsernameHandler.unsubscribe() - }) -} + emitter(JSON.parse(event.body)); + }); + return () => receiveUsernameHandler.unsubscribe(); + }); +}; -- cgit