@@ -28,6 +28,21 @@ interface QueryOptions {
2828
2929type QueryResult < U > = QueryObserverResult < U [ ] , Error > ;
3030
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+
3146export const createResourceStream = < T extends Resource , K extends keyof T > (
3247 client : { current : T | undefined } ,
3348 method : K ,
@@ -55,15 +70,8 @@ export const createResourceStream = <T extends Resource, K extends keyof T>(
5570 const name = $derived ( client . current ?. name ) ;
5671 const methodName = $derived ( String ( method ) ) ;
5772 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 ) ) ;
6775
6876 function processStream ( ) {
6977 const clientFunc = client . current ?. [ method ] ;
0 commit comments