@@ -28,6 +28,21 @@ interface QueryOptions {
28
28
29
29
type QueryResult < U > = QueryObserverResult < U [ ] , Error > ;
30
30
31
+ export const streamQueryKey = (
32
+ partID : string ,
33
+ name : string | undefined ,
34
+ methodName : string ,
35
+ args ?: QueryOptions | unknown
36
+ ) => [
37
+ 'viam-svelte-sdk' ,
38
+ 'partID' ,
39
+ partID ,
40
+ 'resource' ,
41
+ name ,
42
+ methodName ,
43
+ ...( args ? [ args ] : [ ] ) ,
44
+ ] ;
45
+
31
46
export const createResourceStream = < T extends Resource , K extends keyof T > (
32
47
client : { current : T | undefined } ,
33
48
method : K ,
@@ -55,15 +70,8 @@ export const createResourceStream = <T extends Resource, K extends keyof T>(
55
70
const name = $derived ( client . current ?. name ) ;
56
71
const methodName = $derived ( String ( method ) ) ;
57
72
const refetchMode = $derived ( _options ?. refetchMode ?? 'reset' ) ;
58
- const queryKey = $derived ( [
59
- 'viam-svelte-sdk' ,
60
- 'partID' ,
61
- ( client . current as T & { partID : string } ) ?. partID ,
62
- 'resource' ,
63
- name ,
64
- methodName ,
65
- ...( _args ? [ _args ] : [ ] ) ,
66
- ] ) ;
73
+ const partID = $derived ( ( client . current as T & { partID : string } ) ?. partID ) ;
74
+ const queryKey = $derived ( streamQueryKey ( partID , name , methodName , _args ) ) ;
67
75
68
76
function processStream ( ) {
69
77
const clientFunc = client . current ?. [ method ] ;
0 commit comments