mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
updates socket.ts (renames and add method)
This commit is contained in:
parent
45ede860d9
commit
a750644c20
@ -9,15 +9,28 @@ console.debug('Websocket: ', URL);
|
|||||||
|
|
||||||
export const socket = io(URL, { path: '/ws/socket.io', transports: ['websocket'] });
|
export const socket = io(URL, { path: '/ws/socket.io', transports: ['websocket'] });
|
||||||
|
|
||||||
export const emit_update = (
|
export const setAttribute = (
|
||||||
name: string,
|
name: string,
|
||||||
parentPath: string,
|
parentPath: string,
|
||||||
value: unknown,
|
value: unknown,
|
||||||
callback?: (ack: unknown) => void
|
callback?: (ack: unknown) => void
|
||||||
) => {
|
) => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
socket.emit('frontend_update', { name, parent_path: parentPath, value }, callback);
|
socket.emit('set_attribute', { name, parent_path: parentPath, value }, callback);
|
||||||
} else {
|
} else {
|
||||||
socket.emit('frontend_update', { name, parent_path: parentPath, value });
|
socket.emit('set_attribute', { name, parent_path: parentPath, value });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const runMethod = (
|
||||||
|
name: string,
|
||||||
|
parentPath: string,
|
||||||
|
kwargs: Record<string, unknown>,
|
||||||
|
callback?: (ack: unknown) => void
|
||||||
|
) => {
|
||||||
|
if (callback) {
|
||||||
|
socket.emit('run_method', { name, parent_path: parentPath, kwargs }, callback);
|
||||||
|
} else {
|
||||||
|
socket.emit('run_method', { name, parent_path: parentPath, kwargs });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user