@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 11 lines 667 Bytes
Raw
1 import * as Effect from "effect/Effect";
2
3 // Effect's own yield resumes through `setImmediate` where the host defines it and a
4 // zero-delay timer otherwise. React Native's `setImmediate` is a microtask shim, so
5 // nothing from the host runs before the fiber resumes. A timer yields on every host;
6 // a browser can pass a yield that its timer clamping and throttling do not slow.
7 export const yieldToHostTimer = Effect.callback<void>((resume) => {
8 // @effect-diagnostics-next-line globalTimersInEffect:off - A host timer, not Effect.sleep, is the point.
9 const timer = setTimeout(() => resume(Effect.void), 0);
10 return Effect.sync(() => clearTimeout(timer));
11 });