diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-22 21:26:19 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-22 21:31:17 +0100 |
commit | b3a5f5cbc343ffdd654de70262847220e9533adc (patch) | |
tree | 1e1601132e22aecf8ae61668f2ce54e2c25eb660 | |
parent | Make login input large (diff) | |
download | seven-wonders-b3a5f5cbc343ffdd654de70262847220e9533adc.tar.gz seven-wonders-b3a5f5cbc343ffdd654de70262847220e9533adc.tar.bz2 seven-wonders-b3a5f5cbc343ffdd654de70262847220e9533adc.zip |
Fix websocket value when no message body is received
-rw-r--r-- | frontend/src/api/websocket.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/frontend/src/api/websocket.js b/frontend/src/api/websocket.js index 6813676c..2fc045ff 100644 --- a/frontend/src/api/websocket.js +++ b/frontend/src/api/websocket.js @@ -7,7 +7,7 @@ const DEFAULT_DEBUG_OPTIONS = { debug: process.env.NODE_ENV !== 'production', }; -export type Callback<T> = (value?: T) => void; +export type Callback<T> = (value: T) => void; export type UnsubscribeFn = () => void; export type SubscribeFn<T> = (callback: Callback<T>) => UnsubscribeFn; @@ -28,7 +28,7 @@ export class JsonStompClient { const socketSubscription: Subscription = this.client.subscribe(path, (message: Message) => { // not all frames have a JSON body const value: T | void = message && JsonStompClient.parseBody(message); - callback(value); + callback(value || {}); }); return () => socketSubscription.unsubscribe(); } |