File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1- import type { Resource , RobotClient } from '@viamrobotics/sdk' ;
1+ import {
2+ type Resource ,
3+ type RobotClient ,
4+ MachineConnectionEvent ,
5+ } from '@viamrobotics/sdk' ;
26
3- import { useRobotClient } from './robot-clients.svelte' ;
7+ import { useConnectionStatus , useRobotClient } from './robot-clients.svelte' ;
48
59export type Client < T > = new ( part : RobotClient , name : string ) => T ;
610
@@ -10,12 +14,17 @@ export const createResourceClient = <T extends Resource>(
1014 resourceName : ( ) => string
1115) : { current : T | undefined } => {
1216 const robotClient = useRobotClient ( partID ) ;
17+ const connectionStatus = useConnectionStatus ( partID ) ;
1318
1419 const resourceClient = $derived . by < T | undefined > ( ( ) => {
1520 if ( ! robotClient . current ) {
1621 return ;
1722 }
1823
24+ if ( connectionStatus . current !== MachineConnectionEvent . CONNECTED ) {
25+ return ;
26+ }
27+
1928 const nextClient = new client ( robotClient . current , resourceName ( ) ) ;
2029
2130 // PartIDs are used to invalidate queries for this client
You can’t perform that action at this time.
0 commit comments