diff options
author | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-20 15:14:13 +0200 |
---|---|---|
committer | Victor Chabbert <chabbertvi@eisti.eu> | 2017-05-20 15:14:13 +0200 |
commit | 240246ea132cc736c6eaa70ed79f2ec78d1d4636 (patch) | |
tree | a45a5c81de9f650fcd18190d90049f67c0f63b97 /frontend/src/utils/websocket.js | |
parent | Upgrade react-scripts to 1.0.1 (diff) | |
download | seven-wonders-240246ea132cc736c6eaa70ed79f2ec78d1d4636.tar.gz seven-wonders-240246ea132cc736c6eaa70ed79f2ec78d1d4636.tar.bz2 seven-wonders-240246ea132cc736c6eaa70ed79f2ec78d1d4636.zip |
Add prettier and format js files
Diffstat (limited to 'frontend/src/utils/websocket.js')
-rw-r--r-- | frontend/src/utils/websocket.js | 35 |
1 files changed, 20 insertions, 15 deletions
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(); + }); +}; |