MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / waitForCondition

Function waitForCondition

apps/cli/src/daemon.ts:186–203  ·  view source on GitHub ↗
(input: {
  readonly check: Effect.Effect<boolean, E, R>;
  readonly expected: boolean;
  readonly timeoutMs: number;
  readonly intervalMs: number;
})

Source from the content-addressed store, hash-verified

184 : signalPid(-child.pid).pipe(Effect.catch(() => signalPid(child.pid)));
185
186const waitForCondition = <E, R>(input: {
187 readonly check: Effect.Effect<boolean, E, R>;
188 readonly expected: boolean;
189 readonly timeoutMs: number;
190 readonly intervalMs: number;
191}): Effect.Effect<boolean, E, R> =>
192 Effect.gen(function* () {
193 const startedAt = yield* Clock.currentTimeMillis;
194 while (true) {
195 const reachable = yield* input.check;
196 if (reachable === input.expected) return true;
197
198 const now = yield* Clock.currentTimeMillis;
199 if (now - startedAt >= input.timeoutMs) return false;
200
201 yield* Effect.sleep(input.intervalMs);
202 }
203 });
204
205export const waitForReachable = <E, R>(input: {
206 readonly check: Effect.Effect<boolean, E, R>;

Callers 2

waitForReachableFunction · 0.85
waitForUnreachableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected