(enabled: Accessor<boolean> = () => true)
| 46 | }); |
| 47 | |
| 48 | export function createDevicesQuery(enabled: Accessor<boolean> = () => true) { |
| 49 | const query = useQuery(() => ({ |
| 50 | ...devicesSnapshot, |
| 51 | enabled: enabled(), |
| 52 | refetchInterval: enabled() ? devicesSnapshot.refetchInterval : false, |
| 53 | })); |
| 54 | |
| 55 | createEffect(() => { |
| 56 | const unlisten = events.devicesUpdated.listen(() => { |
| 57 | if (!enabled()) return; |
| 58 | query.refetch(); |
| 59 | }); |
| 60 | |
| 61 | onCleanup(() => { |
| 62 | unlisten.then((fn) => fn()); |
| 63 | }); |
| 64 | }); |
| 65 | |
| 66 | return query; |
| 67 | } |
| 68 | |
| 69 | type CameraDetailsCache = Record< |
| 70 | string, |
no outgoing calls
no test coverage detected