Skip to content

Commit 395a64a

Browse files
authored
Merge branch 'main' into persist-query-logging-settings
2 parents 59019a5 + 2c765ed commit 395a64a

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @viamrobotics/svelte-sdk
22

3+
## 0.7.2
4+
5+
### Patch Changes
6+
7+
- 530af6c: do not create resource clients until connected
8+
39
## 0.7.1
410

511
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@viamrobotics/svelte-sdk",
33
"description": "Build Svelte apps with Viam",
44
"license": "Apache-2.0",
5-
"version": "0.7.1",
5+
"version": "0.7.2",
66
"scripts": {
77
"dev": "vite dev",
88
"build": "vite build && npm run prepack",

src/lib/hooks/create-resource-client.svelte.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
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

59
export 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

0 commit comments

Comments
 (0)