MCPcopy Index your code
hub / github.com/anomalyco/opencode / eventuallyUpdate

Function eventuallyUpdate

packages/core/test/filesystem/watcher.test.ts:108–120  ·  view source on GitHub ↗
(check: (event: WatcherEvent) => boolean, trigger: () => Effect.Effect<void, E>)

Source from the content-addressed store, hash-verified

106}
107
108function eventuallyUpdate<E>(check: (event: WatcherEvent) => boolean, trigger: () => Effect.Effect<void, E>) {
109 return Effect.gen(function* () {
110 while (true) {
111 const result = yield* maybeNextUpdate(check, trigger(), "250 millis")
112 if (Option.isSome(result)) return result.value
113 }
114 }).pipe(
115 Effect.timeoutOrElse({
116 duration: "5 seconds",
117 orElse: () => Effect.fail(new Error("timed out waiting for file watcher readiness")),
118 }),
119 )
120}
121
122function noUpdate<E>(check: (event: WatcherEvent) => boolean, trigger: Effect.Effect<void, E>, timeout = 500) {
123 return Effect.acquireUseRelease(

Callers 1

readyFunction · 0.85

Calls 2

maybeNextUpdateFunction · 0.85
triggerFunction · 0.50

Tested by

no test coverage detected