MCPcopy
hub / github.com/anomalyco/opencode / wait

Function wait

packages/core/test/filesystem/watcher.test.ts:72–86  ·  view source on GitHub ↗
(check: (event: WatcherEvent) => boolean)

Source from the content-addressed store, hash-verified

70}
71
72function wait(check: (event: WatcherEvent) => boolean) {
73 return Effect.gen(function* () {
74 const events = yield* EventV2.Service
75 const deferred = yield* Deferred.make<WatcherEvent>()
76 const fiber = yield* events.subscribe(Watcher.Event.Updated).pipe(
77 Stream.runForEach((event) => {
78 if (!check(event.data)) return Effect.void
79 return Deferred.succeed(deferred, event.data).pipe(Effect.asVoid)
80 }),
81 Effect.forkScoped,
82 )
83 yield* Effect.yieldNow
84 return { deferred, fiber }
85 })
86}
87
88function maybeNextUpdate<E>(
89 check: (event: WatcherEvent) => boolean,

Callers 2

maybeNextUpdateFunction · 0.70
noUpdateFunction · 0.70

Calls 3

subscribeMethod · 0.65
checkFunction · 0.50
makeMethod · 0.45

Tested by

no test coverage detected