refactor(core): make watcher subscription effectful

This commit is contained in:
Dax Raad 2026-07-29 09:49:38 -04:00
commit bd906d468d
5 changed files with 49 additions and 34 deletions

View file

@ -393,7 +393,8 @@ export const layer = (options?: Options) => Layer.effect(
const key = JSON.stringify(target)
if (watched.has(key)) continue
watched.add(key)
yield* watcher.subscribe(target).pipe(
const stream = yield* watcher.subscribe(target)
yield* stream.pipe(
Stream.runForEach((update) => PubSub.publish(updates, update)),
Effect.forkScoped({ startImmediately: true }),
)