feat: adding "emit_update" function

This commit is contained in:
Mose Müller
2023-08-02 12:06:22 +02:00
parent c5bbaad58d
commit 80fe1051f1
6 changed files with 27 additions and 37 deletions

View File

@ -8,3 +8,12 @@ const URL = `ws://${hostname}:${port}/`;
console.debug('Websocket: ', URL);
export const socket = io(URL, { path: '/ws/socket.io', transports: ['websocket'] });
export const emit_update = (
name: string,
parent_path: string,
value: unknown,
callback?: (ack: unknown) => void
) => {
socket.emit('frontend_update', { name, parent_path, value }, callback);
};