Use TypeScript interface for websocket calllback

This commit is contained in:
Linus Groh
2020-03-01 20:53:38 +00:00
parent 9ce9933d11
commit b252a6580a
2 changed files with 4 additions and 7 deletions

View File

@@ -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");

3
src/index.d.ts vendored
View File

@@ -201,6 +201,9 @@ interface QueryParams {
layers?: string;
}
/** Callback for new WebSocket location messages. */
interface WebSocketLocationCallback { (): void }
/** A CSS color. */
type Color = string;