MCPcopy Create free account
hub / github.com/anomalyco/opencode / watch

Function watch

packages/opencode/src/share/share-next.ts:166–177  ·  view source on GitHub ↗
(
          def: D,
          fn: (data: EventV2.Data<D>) => Effect.Effect<void, unknown>,
        )

Source from the content-addressed store, hash-verified

164 if (disabled) return cache
165
166 const watch = <D extends EventV2.Definition>(
167 def: D,
168 fn: (data: EventV2.Data<D>) => Effect.Effect<void, unknown>,
169 ) =>
170 events.listen((event) => {
171 if (event.type !== def.type || event.location?.directory !== _ctx.directory) return Effect.void
172 return fn(event.data as EventV2.Data<D>).pipe(
173 Effect.catchCause((cause) =>
174 Effect.logError("share subscriber failed", { type: def.type, cause: cause }),
175 ),
176 )
177 })
178
179 yield* watch(Session.Event.Updated, (data) =>
180 Effect.gen(function* () {

Callers 1

share-next.tsFile · 0.70

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected