28 lines · 1.0 KB · TypeScript
RawDownload
import type { DesktopEnvironmentBootstrap } from "@t3tools/contracts";import { useEffect, useState } from "react"; import { readDesktopSecondaryBootstraps } from "./desktopLocal"; const DESKTOP_LOCAL_BOOTSTRAP_POLL_MS = 2_000; /** * Reactively track the desktop's secondary local backends (e.g. a parallel WSL * backend). The bridge exposes no change event, so we re-read on an interval; * failed reads retain the latest successful snapshot, while a successful empty * read clears it. Use this instead of polling the bridge ad hoc so every * renderer consumer reads the same topology. */export function useDesktopLocalBootstraps(): ReadonlyArray<DesktopEnvironmentBootstrap> {  const [bootstraps, setBootstraps] = useState<ReadonlyArray<DesktopEnvironmentBootstrap>>(    readDesktopSecondaryBootstraps,  );   useEffect(() => {    const read = () => setBootstraps(readDesktopSecondaryBootstraps());    read();    const interval = setInterval(read, DESKTOP_LOCAL_BOOTSTRAP_POLL_MS);    return () => clearInterval(interval);  }, []);   return bootstraps;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t