From b252a6580a5178ca67804dcdb6f0db1d06f6605c Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 1 Mar 2020 20:53:38 +0000 Subject: [PATCH] Use TypeScript interface for websocket calllback --- src/api.js | 8 +------- src/index.d.ts | 3 +++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/api.js b/src/api.js index 2dc6f72..3e57ffe 100644 --- a/src/api.js +++ b/src/api.js @@ -1,12 +1,6 @@ import { log, logLevels } from "@/logging"; import { getApiUrl } from "@/util"; -/** - * Callback for new WebSocket location messages. - * - * @callback webSocketLocationCallback - */ - /** * Fetch an API resource. * @@ -145,7 +139,7 @@ export const getLocationHistory = async (devices, start, end) => { * Connect to the WebSocket API, reconnect when necessary and handle received * messages. * - * @param {webSocketLocationCallback} [callback] Callback for location messages + * @param {WebSocketLocationCallback} [callback] Callback for location messages */ export const connectWebsocket = async callback => { let url = getApiUrl("/ws/last"); diff --git a/src/index.d.ts b/src/index.d.ts index ce0bcd9..563cf33 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -201,6 +201,9 @@ interface QueryParams { layers?: string; } +/** Callback for new WebSocket location messages. */ +interface WebSocketLocationCallback { (): void } + /** A CSS color. */ type Color = string;